phonebookengines/VirtualPhonebook/VPbkCntModel/inc/CContactLink.h
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     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:  The virtual phonebook contact link
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CCONTACTLINK_H
       
    21 #define CCONTACTLINK_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <MVPbkContactLink.h>
       
    25 #include <MVPbkStreamable.h>
       
    26 #include <MVPbkContactLinkPacking.h>
       
    27 #include <MVPbkContactBookmark.h>
       
    28 #include <e32base.h>
       
    29 #include <cntdef.h>
       
    30 #include <e32des8.h>
       
    31 #include "TVPbkContactStoreUriPtr.h"
       
    32 
       
    33 class RReadStream;
       
    34 class CVPbkContactLinkArray;
       
    35 
       
    36 namespace VPbkCntModel {
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CContactStore;
       
    40 
       
    41 // CLASS DECLARATIONS
       
    42 
       
    43 /**
       
    44  * A externalizable Contact link that can be referenced from external systems. 
       
    45  */
       
    46 NONSHARABLE_CLASS( CContactLink ): 
       
    47         public CBase, 
       
    48         public MVPbkContactLink,
       
    49         public MVPbkStreamable,
       
    50         public MVPbkContactLinkPacking,
       
    51         public MVPbkContactBookmark
       
    52     {
       
    53     public: // constructor
       
    54         /**
       
    55          * Construct a new link from aLinkBuf. 
       
    56          * @param aStoreUri  The complete URI of this store
       
    57          */
       
    58         static CContactLink* NewLC( CContactStore& aContactStore, 
       
    59                                    RReadStream& aStream );
       
    60 
       
    61         /**
       
    62          * Construct a new link from aId. 
       
    63          * @param aStoreUri  The complete URI of this store
       
    64          */
       
    65         static CContactLink* NewLC(
       
    66                 CContactStore& aContactStore, 
       
    67                 TContactItemId aId,
       
    68                 TInt aFieldId = KErrNotFound );
       
    69 
       
    70         ~CContactLink();
       
    71 
       
    72     public: // interface
       
    73         /**
       
    74          * Returns ETrue if this aLink's aComponent is from this store. 
       
    75          * @param aStoreUri The complete URI of this store
       
    76          * @param aLink The link
       
    77          * @aComponent  The component that is compared
       
    78          */
       
    79         static TBool Matches( const TDesC& aStoreUri, 
       
    80                 const MVPbkContactLink& aLink,
       
    81                 TVPbkContactStoreUriPtr::TVPbkContactStoreUriComponent 
       
    82                                                         aComponent );
       
    83 
       
    84         /**
       
    85          * Returns ETrue if this aLink is from this store. 
       
    86          * The URI of the link matches this stores URI.
       
    87          * @param aStoreUri The complete URI of this store
       
    88          * @param aLink The link
       
    89          */
       
    90         static TBool Matches( const TVPbkContactStoreUriPtr& aStoreUri, 
       
    91                              const MVPbkContactLink& aLink );
       
    92 
       
    93         /**
       
    94          * Returns the contact model contact id of this link.
       
    95          */
       
    96         TContactItemId ContactId() const;
       
    97         
       
    98         /**
       
    99          * Returns the contact field id of this link.
       
   100          */
       
   101         TInt ContactFieldId() const;
       
   102         
       
   103         /**
       
   104          * Sets the contact model contact id of this link.
       
   105          */
       
   106         void SetContactId( TContactItemId aContactId );
       
   107 
       
   108         /**
       
   109          * Sets the contact field id of this link.
       
   110          */
       
   111         void SetContactFieldId( TInt aContactFieldId );
       
   112 
       
   113         /**
       
   114          * Contact database filename with file type extension.
       
   115          */
       
   116         const TPtrC ContactDbFileName() const;
       
   117 
       
   118     public: // from MVPbkContactLink
       
   119         MVPbkContactStore& ContactStore() const;
       
   120         TBool IsSame( const MVPbkContactLink& aOther ) const;
       
   121         TBool RefersTo( const MVPbkBaseContact& aContact ) const;
       
   122         const MVPbkStreamable* Streamable() const;
       
   123         const MVPbkContactLinkPacking& Packing() const;
       
   124         MVPbkContactLink* CloneLC() const;
       
   125 
       
   126     public: // From MVPbkStreamable
       
   127         void ExternalizeL( RWriteStream& aStream ) const;
       
   128         TInt ExternalizedSize() const;
       
   129 
       
   130     public: // from MVPbkContactLinkPacking
       
   131         TInt InternalPackedSize() const;
       
   132         void PackInternalsL( RWriteStream& aStream ) const;
       
   133 
       
   134     private: // implementation
       
   135         CContactLink( CContactStore& aContactStore );
       
   136         void CommonConstructL();
       
   137         void ConstructL( RReadStream& aStream );
       
   138         void ConstructL( TContactItemId aId, TInt aFieldId );
       
   139 
       
   140     private: // data members
       
   141         /// Ref: Contact store this link belongs to.
       
   142         CContactStore& iContactStore;
       
   143         /// Own: Contact item id
       
   144         TContactItemId iId;
       
   145         /// Own: Contact field id
       
   146         TInt iFieldId;
       
   147         /// Own: a link array for externalizing
       
   148         CVPbkContactLinkArray* iLinkArray;
       
   149     };
       
   150 
       
   151 // INLINE FUNCTIONS
       
   152 
       
   153 } // namespace VPbkCntModel
       
   154 
       
   155 #endif // CCONTACTLINK_H
       
   156 //End of file
       
   157 
       
   158