phonebookui/Phonebook2/inc/CPbk2PresentationContact.h
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Phonebook 2 presentation level contact.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2PRESENTATIONCONTACT_H
       
    20 #define CPBK2PRESENTATIONCONTACT_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MVPbkStoreContact.h>
       
    25 #include <MVPbkStoreContact2.h>
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class MVPbkStoreContact;
       
    29 class MPbk2FieldPropertyArray;
       
    30 class CPbk2PresentationContactFieldCollection;
       
    31 class MVPbkContactGroup;
       
    32 class MPbk2FieldProperty;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37  *  Phonebook 2 presentation level contact.
       
    38  */
       
    39 class CPbk2PresentationContact : public CBase,
       
    40                                  public MVPbkStoreContact,
       
    41                                  public MVPbkStoreContact2                               
       
    42     {
       
    43     public: // Constructors and destructor
       
    44 
       
    45         /**
       
    46          * Creates a new instance of this class.
       
    47          *
       
    48          * @param aStoreContact     The actual store contact that
       
    49          *                          has the data.
       
    50          * @param aFieldProperties  An array of field properties.
       
    51          * @return  A new instance of this class.
       
    52          */
       
    53         IMPORT_C static CPbk2PresentationContact* NewL(
       
    54                 MVPbkStoreContact& aStoreContact,
       
    55                 const MPbk2FieldPropertyArray& aFieldProperties );
       
    56 
       
    57         /**
       
    58          * Destructor.
       
    59          */
       
    60         virtual ~CPbk2PresentationContact();
       
    61 
       
    62     public: // Interface
       
    63 
       
    64         /**
       
    65          * Checks the limits of the fields in the store and
       
    66          * in the UI field property.
       
    67          *
       
    68          * @param aType     The type of the field to be added to the contact.
       
    69          * @return  ETrue if the field can be added to the contact.
       
    70          */
       
    71         IMPORT_C TBool IsFieldAdditionPossibleL(
       
    72                 const MVPbkFieldType& aType ) const;
       
    73 
       
    74         /**
       
    75          * Adds store supported template fields to the contact.
       
    76          * Does not add duplicates.
       
    77          */
       
    78         IMPORT_C void AddSupportedTemplateFieldsL();
       
    79 
       
    80         /**
       
    81          * Returns an array of field properties that can be used to
       
    82          * add fields to the contact. The properties have field types,
       
    83          * and those field types are then possible to add to the contact.
       
    84          * If NULL is returned then it is  not possible to add fields
       
    85          * to the contact.
       
    86          *
       
    87          * @return  An array of field properties or NULL, caller
       
    88          *          owns the array but not the MPbk2FieldProperty instances.
       
    89          */
       
    90         IMPORT_C CArrayPtr<const MPbk2FieldProperty>*
       
    91             AvailableFieldsToAddL() const;
       
    92 
       
    93         /**
       
    94          * Returns Phonebook 2 specific field collection.
       
    95          *
       
    96          * @return  Phonebook 2 specific field collection.
       
    97          */
       
    98         inline CPbk2PresentationContactFieldCollection&
       
    99             PresentationFields() const;
       
   100 
       
   101         /**
       
   102          * Returns the actual store contact this
       
   103          * presentation contact presents.
       
   104          *
       
   105          * @return  Store contact.
       
   106          */
       
   107         inline MVPbkStoreContact& StoreContact() const;
       
   108 
       
   109     public: // From MVPbkStoreContact
       
   110         MVPbkObjectHierarchy& ParentObject() const;
       
   111         const MVPbkStoreContactFieldCollection& Fields() const;
       
   112         TBool IsSame(
       
   113                 const MVPbkStoreContact& aOtherContact ) const;
       
   114         MVPbkContactLink* CreateLinkLC() const;
       
   115         void DeleteL(
       
   116                 MVPbkContactObserver& aObserver ) const;
       
   117         void Close() const;
       
   118         MVPbkContactStore& ParentStore() const;
       
   119         MVPbkStoreContactFieldCollection& Fields();
       
   120         MVPbkStoreContactField* CreateFieldLC(
       
   121                 const MVPbkFieldType& aFieldType ) const;
       
   122         TInt AddFieldL(
       
   123                 MVPbkStoreContactField* aField );
       
   124         void RemoveField(
       
   125                 TInt aIndex );
       
   126         void RemoveAllFields();
       
   127         void LockL(
       
   128                 MVPbkContactObserver& aObserver ) const;
       
   129         void CommitL(
       
   130                 MVPbkContactObserver& aObserver ) const;
       
   131         MVPbkContactLinkArray* GroupsJoinedLC() const;
       
   132         MVPbkContactGroup* Group();
       
   133         TInt MaxNumberOfFieldL(
       
   134                 const MVPbkFieldType& aType ) const;
       
   135         TBool MatchContactStore(
       
   136                 const TDesC& aContactStoreUri ) const;
       
   137         TBool MatchContactStoreDomain(
       
   138                 const TDesC& aContactStoreDomain ) const;
       
   139         MVPbkContactBookmark* CreateBookmarkLC() const;
       
   140         TAny* StoreContactExtension(TUid aExtensionUid);
       
   141         
       
   142       public: // From MVPbkStoreContact2  
       
   143         MVPbkStoreContactProperties* PropertiesL() const;
       
   144         void SetAsOwnL(MVPbkContactObserver& aObserver) const;
       
   145 
       
   146     public:
       
   147         IMPORT_C TInt AddFieldL(
       
   148                 MVPbkStoreContactField* aField, const TDesC& aName );
       
   149     private: // Implementation
       
   150         CPbk2PresentationContact(MVPbkStoreContact& aStoreContact,
       
   151                 const MPbk2FieldPropertyArray& aFieldProperties );
       
   152         void ConstructL();
       
   153         TInt CurrentAmountOfFieldTypeInContact(
       
   154                 const MVPbkFieldType& aType, const TDesC& aName ) const;
       
   155 
       
   156     private: // Data
       
   157         /// Ref: The actual store contact this contact maps to
       
   158         MVPbkStoreContact& iStoreContact;
       
   159         /// Ref: Static field properties
       
   160         const MPbk2FieldPropertyArray& iFieldProperties;
       
   161         /// Own: A collection of field mappers
       
   162         CPbk2PresentationContactFieldCollection* iCollection;
       
   163     };
       
   164 
       
   165 
       
   166 // INLINE IMPLEMENTATION
       
   167 
       
   168 // --------------------------------------------------------------------------
       
   169 // CPbk2PresentationContact::PresentationFields
       
   170 // --------------------------------------------------------------------------
       
   171 //
       
   172 inline CPbk2PresentationContactFieldCollection&
       
   173         CPbk2PresentationContact::PresentationFields() const
       
   174     {
       
   175     return *iCollection;
       
   176     }
       
   177 
       
   178 // --------------------------------------------------------------------------
       
   179 // CPbk2PresentationContact::StoreContact
       
   180 // --------------------------------------------------------------------------
       
   181 //
       
   182 inline MVPbkStoreContact& CPbk2PresentationContact::StoreContact() const
       
   183     {
       
   184     return iStoreContact;
       
   185     }
       
   186 
       
   187 #endif // CPBK2PRESENTATIONCONTACT_H
       
   188 
       
   189 // End of File