phonebookengines/VirtualPhonebook/VPbkSimStore/inc/TStoreContactField.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Implements a sim store contact field
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VPBKSIMSTORE_TSTORECONTACTFIELD_H
       
    20 #define VPBKSIMSTORE_TSTORECONTACTFIELD_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <MVPbkStoreContactField.h>
       
    25 #include "TContactFieldData.h"
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CVPbkSimCntField;
       
    29 
       
    30 namespace VPbkSimStore {
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CContact;
       
    34 
       
    35 // CLASS DECLARATIONS
       
    36 
       
    37 /**
       
    38  * Maps a Contact Model field to a Virtual Phonebook field.
       
    39  */
       
    40 NONSHARABLE_CLASS( TStoreContactField ): 
       
    41         public MVPbkStoreContactField
       
    42     {
       
    43     public:  // Constructors
       
    44         /**
       
    45          * Constructor. Sets the parent contact and resets other data to null 
       
    46          * values.
       
    47          */
       
    48         TStoreContactField();
       
    49 
       
    50     public:  // New functions
       
    51         
       
    52         /**
       
    53          * Sets a new parent contact for this field. Resets the Contact Model 
       
    54          * field mapping to null.
       
    55          */
       
    56         void SetParentContact( CContact& aParentContact );
       
    57 
       
    58         /**
       
    59         * Sets the native sim field for this vpbk field
       
    60         */
       
    61         void SetSimField( CVPbkSimCntField& aSimField );
       
    62         
       
    63     public:  // Functions from base classes
       
    64 
       
    65         /**
       
    66         * From MVPbkObjectHierarchy
       
    67         */
       
    68         MVPbkObjectHierarchy& ParentObject() const;
       
    69 
       
    70         /**
       
    71         * From MVPbkBaseContactField
       
    72         */
       
    73         MVPbkBaseContact& ParentContact() const;
       
    74 
       
    75         /**
       
    76         * From MVPbkBaseContactField
       
    77         */
       
    78         const MVPbkFieldType* MatchFieldType( TInt aMatchPriority ) const;
       
    79         
       
    80         /**
       
    81         * From MVPbkBaseContactField
       
    82         */
       
    83         const MVPbkFieldType* BestMatchingFieldType() const;
       
    84 
       
    85         /**
       
    86         * From MVPbkBaseContactField
       
    87         */
       
    88         const MVPbkContactFieldData& FieldData() const;
       
    89 
       
    90         /**
       
    91         * From MVPbkBaseContactField
       
    92         */
       
    93         TBool IsSame( const MVPbkBaseContactField& aOther ) const;
       
    94         
       
    95         /**
       
    96         * From MVPbkBaseContactField
       
    97         */
       
    98         TBool SupportsLabel() const;
       
    99         
       
   100         /**
       
   101         * From MVPbkStoreContactField
       
   102         */
       
   103         TPtrC FieldLabel() const;
       
   104 
       
   105         /**
       
   106         * From MVPbkStoreContactField
       
   107         */
       
   108         void SetFieldLabelL( const TDesC& aText );
       
   109         
       
   110         /**
       
   111         * From MaxLabelLength
       
   112         */
       
   113         TInt MaxLabelLength() const;
       
   114         
       
   115         /**
       
   116         * From MVPbkStoreContactField
       
   117         */
       
   118         MVPbkContactFieldData& FieldData();
       
   119 
       
   120         /**
       
   121         * From MVPbkStoreContactField
       
   122         */
       
   123         MVPbkStoreContactField* CloneLC() const;
       
   124         
       
   125         /**
       
   126         * From MVPbkStoreContactField
       
   127         */
       
   128         MVPbkContactLink* CreateLinkLC() const;
       
   129         
       
   130     protected:  // New functions
       
   131         
       
   132         /**
       
   133         * Returns the native sim field
       
   134         */
       
   135         inline CVPbkSimCntField* SimField();
       
   136 
       
   137     private:  // Data
       
   138         /// Ref: the contact whose field this is
       
   139         CContact* iParentContact;
       
   140         /// Ref: the native sim field.
       
   141         CVPbkSimCntField* iSimField;
       
   142         /// Own: The data container
       
   143         TContactFieldData iFieldData;
       
   144     };
       
   145 
       
   146 /**
       
   147 * A wrapper class that destroys the native field in destructor
       
   148 * This class is used when client creates a new field.
       
   149 */
       
   150 NONSHARABLE_CLASS( TContactNewField ): public TStoreContactField
       
   151     {
       
   152     public: // Construction and destruction
       
   153 
       
   154         /**
       
   155         * C++ constructor
       
   156         * @param aNewField a new sim field. Ownership is taken
       
   157         */
       
   158         TContactNewField( CVPbkSimCntField* aSimField );
       
   159             
       
   160         // Destructor
       
   161         ~TContactNewField();
       
   162 
       
   163     public: // New functions
       
   164 
       
   165         /**
       
   166         * Returns the sim field and gives up the ownership
       
   167         */
       
   168         CVPbkSimCntField* SimField();
       
   169     private: // Data
       
   170         TBool iOwnsField;
       
   171     };
       
   172 
       
   173 // INLINE FUNCTIONS
       
   174 inline CVPbkSimCntField* TStoreContactField::SimField()
       
   175     {
       
   176     return iSimField;
       
   177     }
       
   178 }  // namespace VPbkSimStore
       
   179 
       
   180 #endif  // VPBKSIMSTORE_TSTORECONTACTFIELD_H
       
   181 //End of file
       
   182 
       
   183