epoc32/include/app/CPbkFieldsInfo.h
branchSymbian3
changeset 4 837f303aceeb
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
       
     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 *     Phonebook field types collection class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __CPbkFieldsInfo_H__
       
    22 #define __CPbkFieldsInfo_H__
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 // This include is not absolutely needed,  but this class is very rarely used 
       
    27 // without class CPbkFieldInfo.
       
    28 #include "CPbkFieldInfo.h"
       
    29 
       
    30 //  FORWARD DECLARATIONS
       
    31 class CContactItem;
       
    32 class CContactItemField;
       
    33 class CContactItemViewDef;
       
    34 class RResourceFile;
       
    35 class CPbkUidMap;
       
    36 class CPbkFieldInfo;
       
    37 class CPbkFieldInfoGroup;
       
    38 class MPbkVcardProperty;
       
    39 class TPbkMatchPriorityLevel;
       
    40 
       
    41 
       
    42 //  CLASS DECLARATION 
       
    43 
       
    44 /**
       
    45  * Phonebook field types collection class. The collection contains 
       
    46  * CPbkFieldInfo objects that contain Phonebook specific field type
       
    47  * information. Each field Phonebook recognizes is associated with 
       
    48  * field info object. The field info objects are references to elements
       
    49  * in this array.
       
    50  */
       
    51 class CPbkFieldsInfo : 
       
    52         public CBase
       
    53 	{
       
    54 	public: // interface
       
    55         /**
       
    56          * Creates and returns an instance of this class intialised from 
       
    57          * resources.
       
    58          * 
       
    59          * @param aPbkResFile       Phonebook's resource file.
       
    60          * @param aCntModelResFile  Contact Model's resource file.
       
    61          */
       
    62         static CPbkFieldsInfo* NewL
       
    63             (RResourceFile& aPbkResFile, RResourceFile& aCntModelResFile);
       
    64 
       
    65         /**
       
    66          * Destructor.
       
    67          */
       
    68         ~CPbkFieldsInfo();
       
    69 
       
    70         /**
       
    71          * Search field info by Phonebook field id.
       
    72          *
       
    73          * @param aFieldId  Phonebook field id to search from the array
       
    74          * @return  The <it>first</it> (there may be several that match) field 
       
    75          *          info object in the field UI presentation order matching 
       
    76          *          aFieldId. Returns NULL if no match is found.
       
    77          */
       
    78         IMPORT_C CPbkFieldInfo* Find(TPbkFieldId aFieldId) const;
       
    79 
       
    80         /**
       
    81          * Search field info by Phonebook field id and location
       
    82          *
       
    83          * @param aFieldId   Phonebook field id to search from the array
       
    84          * @param aLocation  Field location (home/work/none) to search from the array
       
    85          * @return  The field info object (there should be only one) matching 
       
    86          *          aFieldId and aLocation. NULL if no match found.
       
    87          */
       
    88         IMPORT_C CPbkFieldInfo* Find
       
    89 			(TPbkFieldId aFieldId, TPbkFieldLocation aLocation) const;
       
    90 
       
    91         /**
       
    92          * Search a field info matching contact model field.
       
    93          *
       
    94          * @param aContactItemField Contact item field whose match is searched
       
    95          *                          from all field info objects.
       
    96          * @return  The field info object matching aContactItemField. NULL if 
       
    97          *          no match is found.
       
    98          */
       
    99         IMPORT_C CPbkFieldInfo* Find
       
   100 			(const CContactItemField& aContactItemField) const;
       
   101 
       
   102         /**
       
   103          * @internal Only Phonebook internal use is supported!
       
   104          * Creates and returns an initialized matching priority level object.
       
   105          * @deprecated
       
   106          */
       
   107         IMPORT_C TPbkMatchPriorityLevel CreateMatchPriority() const;
       
   108 
       
   109         /**
       
   110          * @internal Only Phonebook internal use is supported!
       
   111          * Searches a match for a contact model field.
       
   112          *
       
   113          * @param aContactItemField Contact item field whose match is searched
       
   114          *                          from all field info objects.
       
   115          * @param aMatchPriority    Priority to match against. Only import
       
   116          *                          types of this priority are checked.
       
   117          * @return  A match information object.
       
   118          * @deprecated
       
   119          */
       
   120         CPbkFieldInfo* Match
       
   121             (const CContactItemField& aContactItemField,
       
   122             const TPbkMatchPriorityLevel& aMatchPriority) const;
       
   123 
       
   124         /**
       
   125          * @internal Only Phonebook internal use is supported!
       
   126          * Searches a match for a vCard property.
       
   127          *
       
   128          * @param aVcardProperty    vCard property to search for a match from 
       
   129          *                          all field info objects.
       
   130          * @param aMatchPriority    Priority to match against. Only import
       
   131          *                          types of this priority are checked.
       
   132          * @return  A match information object.
       
   133          * @deprecated
       
   134          */
       
   135         IMPORT_C CPbkFieldInfo* Match
       
   136             (const MPbkVcardProperty& aVcardProperty,
       
   137             const TPbkMatchPriorityLevel& aMatchPriority) const;
       
   138         
       
   139         /**
       
   140          * Returns the count of field infos.
       
   141          * @return The count of field information elements in this container.
       
   142          */
       
   143         IMPORT_C TInt Count() const;
       
   144 
       
   145         /**
       
   146          * Returns the aIndex:th field info. Field info objects are sorted by
       
   147          * the field presentation ordering.
       
   148          * @param aIndex    The indexed element in this array.
       
   149          * @return The element in the indexed position in the array.
       
   150          */
       
   151         IMPORT_C CPbkFieldInfo* operator[](TInt aIndex) const;
       
   152 
       
   153         /**
       
   154          * Returns the count of field info groups.
       
   155          * @return The count of field info groups.
       
   156          */
       
   157         IMPORT_C TInt GroupCount() const;
       
   158 
       
   159         /**
       
   160          * Returns the field info group at aIndex.
       
   161          * @return The field info group at aIndex.
       
   162          */
       
   163         IMPORT_C const CPbkFieldInfoGroup& GroupAt(TInt aIndex) const;
       
   164 
       
   165         /**
       
   166          * Creates a contact item view definition from an array of Phonebook 
       
   167          * field ids.
       
   168          *
       
   169          * @param aFieldTypes   Array of Phonebook field types.
       
   170          * @return A new contact item view definition.
       
   171          */
       
   172         IMPORT_C CContactItemViewDef* CreateContactItemViewDefLC
       
   173             (const CPbkFieldIdArray& aFieldTypes) const;
       
   174 
       
   175         /**
       
   176          * Creates contact item field definition from an array of Phonebook 
       
   177          * field ids.
       
   178          *
       
   179          * @param aFieldTypes   Phonebook field types to add into the returned
       
   180          *                      array. If NULL an array matching all fields is
       
   181          *                      returned.
       
   182          * @return  A field def array matching <it>at least fields</it> in 
       
   183          *          aFieldTypes. Please note that the returned field definition
       
   184          *          may also match other fields than those specified.
       
   185          */
       
   186         IMPORT_C CContactItemFieldDef* CreateContactItemFieldDefLC
       
   187             (const CPbkFieldIdArray* aFieldTypes) const;
       
   188 
       
   189         /**
       
   190          * Adds fields from resource readers. Doesn't read or link group
       
   191          * information.
       
   192          * @param aPbkResReader Initialized resource buffer 
       
   193          *                      to PHONEBOOK_FIELD_ARRAY
       
   194          * @param aCntModelResReader Initialized resource buffer to 
       
   195          *                           ARRAY or FIELDs
       
   196          * @param aAddedFieldTypes  If not null the field types that were 
       
   197          *                          added are appended to this array. The field
       
   198          *                          types are in the order they were defined in
       
   199          *                          resources.
       
   200          */
       
   201         void AddFieldTypesFromResourceL
       
   202             (TResourceReader& aPbkResReader, 
       
   203             TResourceReader& aCntModelResReader,
       
   204             RArray<const CPbkFieldInfo*>* aAddedFieldTypes);
       
   205 
       
   206     private:  // Implementation
       
   207         CPbkFieldsInfo();
       
   208         CPbkFieldInfoGroup* FindGroup(TPbkFieldGroupId aGroupId);
       
   209         void LinkGroupsL();
       
   210         void ReadGroupsInfoL(RResourceFile& aResFile);
       
   211         void ConstructFromResourceL
       
   212             (RResourceFile& aPbkResFile, RResourceFile& aCntModelResFile);
       
   213         void ReadFieldInfoParamsL();
       
   214 
       
   215     private: // data
       
   216         /// Own: array of field infos
       
   217         RPointerArray<CPbkFieldInfo> iEntries;
       
   218         /// Own: field info groups
       
   219         RPointerArray<CPbkFieldInfoGroup> iGroups;
       
   220         /// Own: UID map for field content type matching
       
   221         CPbkUidMap* iTypeUidMap;
       
   222         /// Own: highest field matching priority level
       
   223         TInt iHighestMatchPriorityLevel;
       
   224         /// Own: configuration data for field infos
       
   225         CPbkFieldInfo::TPbkFieldInfoParams* iPbkFieldInfoParams;
       
   226     };
       
   227 
       
   228 #endif // __CPbkFieldsInfo_H__
       
   229 
       
   230 // End of File