2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: An array for contact links.
19 #ifndef CVPBKCONTACTLINKARRAY_H
20 #define CVPBKCONTACTLINKARRAY_H
24 #include <mvpbkcontactlinkarray.h>
26 // FORWARD DECLARATIONS
27 class MVPbkContactStoreList;
30 class MVPbkContactStoreLoader;
36 * A read-only array of contact links.
39 class CVPbkContactLinkArray :
41 public MVPbkContactLinkArray
43 public: // Constructors and Destructor
45 * Creates an empty link array.
47 * @return A new instance of this class
49 IMPORT_C static CVPbkContactLinkArray* NewL();
52 * Creates an empty link array. Leaves the created array object on
55 * @return A new instance of this class
57 IMPORT_C static CVPbkContactLinkArray* NewLC();
60 * Creates a link array from a packed descriptor of links.
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
68 IMPORT_C static CVPbkContactLinkArray* NewLC(
69 const TDesC8& aPackedLinks,
70 const MVPbkContactStoreList& aStoreList);
73 * Creates a link array from a stream of links.
75 * @param aStream a stream of contact link that was created
76 * using MVPbkStreamable interface of
78 * @param aStoreList the list of stores that contain the
79 * stores that links belong.
80 * @return A new instance of this class
82 IMPORT_C static CVPbkContactLinkArray* NewLC(
84 const MVPbkContactStoreList& aStoreList);
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.
91 * @param aStream a stream of contact link that was created
92 * using MVPbkStreamable interface of
94 * @param aLoader the contact store loader for internalization.
95 * @return A new instance of this class
97 static CVPbkContactLinkArray* NewLC(
99 MVPbkContactStoreLoader& aLoader );
104 ~CVPbkContactLinkArray();
108 * Appends a link to this array.
110 * @param aLink the link object to append. This array takes ownership
111 * of the link if append is succesful.
113 * @post Array count is increased by one and the link is in the last
114 * element of the array.
116 IMPORT_C void AppendL(MVPbkContactLink* aLink);
119 * Inserts a link to this array.
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.
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.
130 IMPORT_C void InsertL(MVPbkContactLink* aLink, TInt aIndex);
133 * Removes a link at aIndex from this array.
135 * @pre aIndex >= 0 && aIndex <= Count()
136 * @post The array count is decreased by one.
138 IMPORT_C void Remove(TInt aIndex);
141 * Removes and deletes a link at aIndex from this array.
143 * @pre aIndex >= 0 && aIndex <= Count()
144 * @post The array count is decreased by one.
146 IMPORT_C void Delete(TInt aIndex);
149 * Resets the array and destroys the links
151 IMPORT_C void ResetAndDestroy();
154 * Resets this array but doesn't destroy links
158 IMPORT_C void Reset();
161 * Returns the size of the packed link array
163 IMPORT_C TInt PackedBufferSize() const;
165 public: // from MVPbkContactLinkArray
167 const MVPbkContactLink& At(TInt aIndex) const;
168 TInt Find(const MVPbkContactLink& aLink) const;
169 HBufC8* PackLC() const;
170 const MVPbkStreamable* Streamable() const;
172 private: // implementation
173 CVPbkContactLinkArray();
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);
189 ///Own: contained contact links
190 RPointerArray<MVPbkContactLink> iLinks;
192 /// Own: an internal class for saving link URIs
193 CStoreUris* iStoreUris;
194 /// Ref: a reference to the contact store loader
195 MVPbkContactStoreLoader* iStoreLoader;
198 #endif // CVPBKCONTACTLINKARRAY_H