epoc32/include/app/CVPbkContactLinkArray.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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:  An array for contact links.
    15 *
    16 */
    17 
    18 
    19 #ifndef CVPBKCONTACTLINKARRAY_H
    20 #define CVPBKCONTACTLINKARRAY_H
    21 
    22 // INCLUDES
    23 #include <e32base.h>
    24 #include <mvpbkcontactlinkarray.h>
    25 
    26 // FORWARD DECLARATIONS
    27 class MVPbkContactStoreList;
    28 class RWriteStream;
    29 class RReadStream;
    30 class MVPbkContactStoreLoader;
    31 
    32 
    33 // CLASS DECLARATIONS
    34 
    35 /**
    36  * A read-only array of contact links.
    37  * @lib VPbkEng.lib
    38  */
    39 class CVPbkContactLinkArray : 
    40         public CBase, 
    41         public MVPbkContactLinkArray
    42     {
    43     public: // Constructors and Destructor
    44         /**
    45          * Creates an empty link array.
    46          *
    47          * @return A new instance of this class
    48          */
    49         IMPORT_C static CVPbkContactLinkArray* NewL();
    50 
    51         /**
    52          * Creates an empty link array. Leaves the created array object on
    53          * the cleanup stack.
    54          *
    55          * @return A new instance of this class
    56          */
    57         IMPORT_C static CVPbkContactLinkArray* NewLC();
    58 
    59         /**
    60          * Creates a link array from a packed descriptor of links.
    61          *
    62          * @param aPackedLinks a buffer that was created using PackLC
    63          *        of MVPbkContactLinkArray or MVPbkContactLink
    64          * @param aStoreList the list of stores that contain the
    65          *        stores that links belong.
    66          * @return A new instance of this class
    67          */
    68         IMPORT_C static CVPbkContactLinkArray* NewLC(
    69                 const TDesC8& aPackedLinks,
    70                 const MVPbkContactStoreList& aStoreList);
    71         
    72         /**
    73          * Creates a link array from a stream of links.
    74          *
    75          * @param aStream a stream of contact link that was created
    76          *                using MVPbkStreamable interface of
    77          *                MVPbkContactLink
    78          * @param aStoreList the list of stores that contain the
    79          *                stores that links belong.
    80          * @return A new instance of this class
    81          */
    82         IMPORT_C static CVPbkContactLinkArray* NewLC(
    83                 RReadStream& aStream,
    84                 const MVPbkContactStoreList& aStoreList);
    85         
    86         /**
    87          * Creates a link array from a stream of links. Uses aLoader
    88          * to find and load stores.
    89          * aLoader must exist the life time of this object.
    90          *
    91          * @param aStream a stream of contact link that was created
    92          *                using MVPbkStreamable interface of
    93          *                MVPbkContactLink
    94          * @param aLoader the contact store loader for internalization.
    95          * @return A new instance of this class
    96          */
    97         static CVPbkContactLinkArray* NewLC(
    98                 RReadStream& aStream,
    99                 MVPbkContactStoreLoader& aLoader );
   100         
   101         /**
   102          * Destructor.
   103          */
   104         ~CVPbkContactLinkArray();
   105 
   106     public:  // interface
   107         /**
   108          * Appends a link to this array.
   109          *
   110          * @param aLink the link object to append. This array takes ownership
   111          *              of the link if append is succesful.
   112          * @pre aLink != NULL
   113          * @post Array count is increased by one and the link is in the last 
   114          * element of the array.
   115          */
   116         IMPORT_C void AppendL(MVPbkContactLink* aLink);
   117 
   118         /**
   119          * Inserts a link to this array.
   120          *
   121          * @param aLink the link object to insert. This array takes ownership
   122          *              of the link if insertion is succesful.
   123          * @param aIndex    position where to insert the link.
   124          * @exception KErrNoMemory  if out of memory.
   125          * @pre aLink != NULL
   126          * @pre aIndex >= 0 && aIndex <= Count()
   127          * @post Array count is increased by one and the link is in the position 
   128          * marked by the aIndex element of the array.
   129          */
   130         IMPORT_C void InsertL(MVPbkContactLink* aLink, TInt aIndex);
   131 
   132         /**
   133          * Removes a link at aIndex from this array.
   134          *  
   135          * @pre aIndex >= 0 && aIndex <= Count()
   136          * @post The array count is decreased by one.
   137          */
   138         IMPORT_C void Remove(TInt aIndex);
   139         
   140         /**
   141          * Removes and deletes a link at aIndex from this array.
   142          *
   143          * @pre aIndex >= 0 && aIndex <= Count()
   144          * @post The array count is decreased by one.
   145          */
   146         IMPORT_C void Delete(TInt aIndex);
   147 
   148         /**
   149          * Resets the array and destroys the links
   150          */
   151         IMPORT_C void ResetAndDestroy();
   152         
   153         /**
   154          * Resets this array but doesn't destroy links
   155          * 
   156          * @post Count() == 0
   157          */
   158         IMPORT_C void Reset();
   159         
   160         /**
   161          * Returns the size of the packed link array
   162          */
   163         IMPORT_C TInt PackedBufferSize() const;
   164 
   165     public: // from MVPbkContactLinkArray
   166         TInt Count() const;
   167         const MVPbkContactLink& At(TInt aIndex) const;
   168         TInt Find(const MVPbkContactLink& aLink) const;
   169         HBufC8* PackLC() const;
   170         const MVPbkStreamable* Streamable() const;
   171     
   172     private: // implementation
   173         CVPbkContactLinkArray();
   174         void ConstructL();
   175         void ConstructL(const TDesC8& aPackedLinks, 
   176                 const MVPbkContactStoreList& aOperations);
   177         void ConstructL(RReadStream& aStream, 
   178                 const MVPbkContactStoreList& aOperations);
   179         TInt DoCalculatePackedBufferSizeV2() const;
   180         void DoFillPackedBufferV2L(RWriteStream& aWriteStream) const;
   181         void InternalizeFromBufferL( RReadStream& aReadStream, 
   182                 const MVPbkContactStoreList& aStoreList );
   183         void DoInternalizeFromBufferL( RReadStream& aReadStream, 
   184                 const MVPbkContactStoreList& aStoreList);
   185         void DoInternalizeFromBufferV2L(RReadStream& aReadStream, 
   186                 const MVPbkContactStoreList& aStoreList);
   187 
   188     private:  // Data
   189         ///Own: contained contact links
   190         RPointerArray<MVPbkContactLink> iLinks;
   191         class CStoreUris;
   192         /// Own: an internal class for saving link URIs
   193         CStoreUris* iStoreUris;
   194         /// Ref: a reference to the contact store loader
   195         MVPbkContactStoreLoader* iStoreLoader;
   196     };
   197 
   198 #endif // CVPBKCONTACTLINKARRAY_H
   199 
   200 // End of file