emailcontacts/contactactionservice/inc/CFscContactNameFormatterBase.h
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2008 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:  A base class for contact name formatters
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CFSCCONTACTNAMEFORMATTERBASE_H
       
    20 #define CFSCCONTACTNAMEFORMATTERBASE_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MPbk2ContactNameFormatter.h>
       
    25 #include "TFscSortOrderFieldMapper.h"
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CPbk2SortOrderManager;
       
    29 class MVPbkFieldTypeList;
       
    30 class CVPbkFieldTypeRefsList;
       
    31 class CVPbkFieldTypeSelector;
       
    32 class TResourceReader;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37  *  A base class for contact name formatters
       
    38  *
       
    39  */
       
    40 NONSHARABLE_CLASS( CFscContactNameFormatterBase )
       
    41 : public CBase,
       
    42 public MPbk2ContactNameFormatter
       
    43     {
       
    44 public: // Constructors and destructor
       
    45 
       
    46     /**
       
    47      * Destructor.
       
    48      */
       
    49     virtual ~CFscContactNameFormatterBase();
       
    50 
       
    51 public: // Functions from MPbk2ContactNameFormatter
       
    52 
       
    53     HBufC* GetContactTitleOrNullL(
       
    54             const MVPbkBaseContactFieldCollection& aContactFields,
       
    55             TUint32 aFormattingFlags);
       
    56     HBufC* GetContactTitleL(
       
    57             const MVPbkBaseContactFieldCollection& aContactFields,
       
    58             TUint32 aFormattingFlags);
       
    59     virtual void GetContactTitle(
       
    60             const MVPbkBaseContactFieldCollection& aContactFields,
       
    61             TDes& aTitle,
       
    62             TUint32 aFormattingFlags) = 0;
       
    63     virtual void GetContactTitleForFind(
       
    64             const MVPbkBaseContactFieldCollection& aContactFields,
       
    65             TDes& aTitle,
       
    66             TUint32 aFormattingFlags) = 0;
       
    67 
       
    68     const TDesC& UnnamedText() const;
       
    69     TBool IsTitleField(
       
    70             const MVPbkBaseContactField& aContactField) const;
       
    71     TBool IsTitleFieldType(
       
    72             const MVPbkFieldType& aFieldType) const;
       
    73     virtual CVPbkBaseContactFieldTypeListIterator* ActualTitleFieldsLC(
       
    74             CVPbkFieldTypeRefsList& aFieldTypeList,
       
    75             const MVPbkBaseContactFieldCollection& aContactFields ) = 0;
       
    76     virtual TInt MaxTitleLength(
       
    77             const MVPbkBaseContactFieldCollection& aContactFields,
       
    78             const TUint32 aFormattingFlags) = 0;
       
    79     virtual TInt MaxTitleLengthForFind(
       
    80             const MVPbkBaseContactFieldCollection& aContactFields,
       
    81             const TUint32 aFormattingFlags) = 0;
       
    82     virtual TBool IsFindSeparatorChar( TChar aCh ) = 0;
       
    83 
       
    84 protected: // New functions
       
    85 
       
    86     /**
       
    87      * Field mapper returns fields from the given contact fields
       
    88      * in the order defined by iSortOrderManager. Must be called
       
    89      * from sub class functions
       
    90      * @param aContactFields current fields
       
    91      */
       
    92     void SetFieldMapper(
       
    93             const MVPbkBaseContactFieldCollection& aContactFields );
       
    94 
       
    95     /**
       
    96      * Get contact title according to given sort order positions
       
    97      *
       
    98      * @param aTitle a descriptor for adding data
       
    99      * @param aFormattingFlags flags from the client
       
   100      * @param aStartingPosition the index of the first type
       
   101      *           in the sort order that is used for title
       
   102      * @param aEndingPosition the index of the last type
       
   103      *           in the sort order that is used for title
       
   104      */
       
   105     void DoGetContactTitle(
       
   106             TDes& aTitle,
       
   107             TUint32 aFormattingFlags,
       
   108             const TInt aStartingPosition,
       
   109             const TInt aEndingPosition);
       
   110 
       
   111     /**
       
   112      * Returns the maximum length of the title
       
   113      *
       
   114      * @param aFormattingFlags flags from the client
       
   115      * @param aStartingPosition the index of the first type
       
   116      *           in the sort order that is used for title
       
   117      * @param aEndingPosition the index of the last type
       
   118      *           in the sort order that is used for title
       
   119      */
       
   120     TInt DoCalculateMaxTitleLength(
       
   121             const TUint32 aFormattingFlags,
       
   122             const TInt aStartingPosition,
       
   123             const TInt aEndingPosition);
       
   124 
       
   125     /**
       
   126      * Return non empty title field types
       
   127      *
       
   128      * @param aFieldTypeList target list where field types are appended
       
   129      * @param aStartingPosition the index of the first type
       
   130      *           in the sort order that is used for title
       
   131      * @param aEndingPosition the index of the last type
       
   132      *           in the sort order that is used for title
       
   133      */
       
   134     void DoAppendNonEmptyTitleFieldTypesL(
       
   135             CVPbkFieldTypeRefsList& aFieldTypeList,
       
   136             const TInt aStartingPosition,
       
   137             const TInt aEndingPosition);
       
   138 
       
   139     /**
       
   140      * Check if title fields are empty
       
   141      *
       
   142      * @param aStartingPosition the index of the first type
       
   143      *           in the sort order that is used for title
       
   144      * @param aEndingPosition the index of the last type
       
   145      *           in the sort order that is used for title
       
   146      * @return ETrue if title fields are empty else EFalse
       
   147      */
       
   148     TBool AreTitleFieldsEmpty(
       
   149             const TInt aStartingPosition,
       
   150             const TInt aEndingPosition ) const;
       
   151 
       
   152 protected:
       
   153 
       
   154     /**
       
   155      * C++ default constructor.
       
   156      */
       
   157     CFscContactNameFormatterBase(
       
   158             const MVPbkFieldTypeList& aMasterFieldTypeList,
       
   159             const CPbk2SortOrderManager& aSortOrderManager);
       
   160 
       
   161     /**
       
   162      * By default Symbian 2nd phase constructor is protected.
       
   163      */
       
   164     void BaseConstructL( const TDesC& aUnnamedText,
       
   165             CVPbkFieldTypeSelector* aTitleFieldSelector );
       
   166 
       
   167 private: // Implementation
       
   168     TBool RequiresSeparatorBetweenNames(
       
   169             const TDesC& aLhs,
       
   170             const TDesC& aRhs) const;
       
   171     void TakePartOfName(
       
   172             const MVPbkBaseContactField* aField,
       
   173             TDes& aTitle,
       
   174             const TUint32 aFormattingFlags,
       
   175             const TBool aUseSeparator) const;
       
   176     void CalculatePartOfName(
       
   177             const MVPbkBaseContactField* aField,
       
   178             TInt& aLength,
       
   179             const TUint32 aFormattingFlags,
       
   180             const TBool aUseSeparator) const;
       
   181 
       
   182 protected: // Data
       
   183     /// Own: Field mapper
       
   184     TFscSortOrderFieldMapper iFieldMapper;
       
   185 
       
   186 private: // Data
       
   187     const MVPbkFieldTypeList& iMasterFieldTypeList;
       
   188     /// Ref: Sort order manager
       
   189     const CPbk2SortOrderManager& iSortOrderManager;
       
   190     /// Own: Text for unnamed contacts
       
   191     HBufC* iUnnamedText;
       
   192     /// Own: Title field selector
       
   193     CVPbkFieldTypeSelector* iTitleFieldSelector;
       
   194     };
       
   195 
       
   196 #endif      // CFSCCONTACTNAMEFORMATTERBASE_H
       
   197 // End of File