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