williamr@4: /* williamr@4: * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: An array for contact links. williamr@4: * williamr@4: */ williamr@4: williamr@4: williamr@4: #ifndef CVPBKCONTACTLINKARRAY_H williamr@4: #define CVPBKCONTACTLINKARRAY_H williamr@4: williamr@4: // INCLUDES williamr@4: #include williamr@4: #include williamr@4: williamr@4: // FORWARD DECLARATIONS williamr@4: class MVPbkContactStoreList; williamr@4: class RWriteStream; williamr@4: class RReadStream; williamr@4: class MVPbkContactStoreLoader; williamr@4: williamr@4: williamr@4: // CLASS DECLARATIONS williamr@4: williamr@4: /** williamr@4: * A read-only array of contact links. williamr@4: * @lib VPbkEng.lib williamr@4: */ williamr@4: class CVPbkContactLinkArray : williamr@4: public CBase, williamr@4: public MVPbkContactLinkArray williamr@4: { williamr@4: public: // Constructors and Destructor williamr@4: /** williamr@4: * Creates an empty link array. williamr@4: * williamr@4: * @return A new instance of this class williamr@4: */ williamr@4: IMPORT_C static CVPbkContactLinkArray* NewL(); williamr@4: williamr@4: /** williamr@4: * Creates an empty link array. Leaves the created array object on williamr@4: * the cleanup stack. williamr@4: * williamr@4: * @return A new instance of this class williamr@4: */ williamr@4: IMPORT_C static CVPbkContactLinkArray* NewLC(); williamr@4: williamr@4: /** williamr@4: * Creates a link array from a packed descriptor of links. williamr@4: * williamr@4: * @param aPackedLinks a buffer that was created using PackLC williamr@4: * of MVPbkContactLinkArray or MVPbkContactLink williamr@4: * @param aStoreList the list of stores that contain the williamr@4: * stores that links belong. williamr@4: * @return A new instance of this class williamr@4: */ williamr@4: IMPORT_C static CVPbkContactLinkArray* NewLC( williamr@4: const TDesC8& aPackedLinks, williamr@4: const MVPbkContactStoreList& aStoreList); williamr@4: williamr@4: /** williamr@4: * Creates a link array from a stream of links. williamr@4: * williamr@4: * @param aStream a stream of contact link that was created williamr@4: * using MVPbkStreamable interface of williamr@4: * MVPbkContactLink williamr@4: * @param aStoreList the list of stores that contain the williamr@4: * stores that links belong. williamr@4: * @return A new instance of this class williamr@4: */ williamr@4: IMPORT_C static CVPbkContactLinkArray* NewLC( williamr@4: RReadStream& aStream, williamr@4: const MVPbkContactStoreList& aStoreList); williamr@4: williamr@4: /** williamr@4: * Creates a link array from a stream of links. Uses aLoader williamr@4: * to find and load stores. williamr@4: * aLoader must exist the life time of this object. williamr@4: * williamr@4: * @param aStream a stream of contact link that was created williamr@4: * using MVPbkStreamable interface of williamr@4: * MVPbkContactLink williamr@4: * @param aLoader the contact store loader for internalization. williamr@4: * @return A new instance of this class williamr@4: */ williamr@4: static CVPbkContactLinkArray* NewLC( williamr@4: RReadStream& aStream, williamr@4: MVPbkContactStoreLoader& aLoader ); williamr@4: williamr@4: /** williamr@4: * Destructor. williamr@4: */ williamr@4: ~CVPbkContactLinkArray(); williamr@4: williamr@4: public: // interface williamr@4: /** williamr@4: * Appends a link to this array. williamr@4: * williamr@4: * @param aLink the link object to append. This array takes ownership williamr@4: * of the link if append is succesful. williamr@4: * @pre aLink != NULL williamr@4: * @post Array count is increased by one and the link is in the last williamr@4: * element of the array. williamr@4: */ williamr@4: IMPORT_C void AppendL(MVPbkContactLink* aLink); williamr@4: williamr@4: /** williamr@4: * Inserts a link to this array. williamr@4: * williamr@4: * @param aLink the link object to insert. This array takes ownership williamr@4: * of the link if insertion is succesful. williamr@4: * @param aIndex position where to insert the link. williamr@4: * @exception KErrNoMemory if out of memory. williamr@4: * @pre aLink != NULL williamr@4: * @pre aIndex >= 0 && aIndex <= Count() williamr@4: * @post Array count is increased by one and the link is in the position williamr@4: * marked by the aIndex element of the array. williamr@4: */ williamr@4: IMPORT_C void InsertL(MVPbkContactLink* aLink, TInt aIndex); williamr@4: williamr@4: /** williamr@4: * Removes a link at aIndex from this array. williamr@4: * williamr@4: * @pre aIndex >= 0 && aIndex <= Count() williamr@4: * @post The array count is decreased by one. williamr@4: */ williamr@4: IMPORT_C void Remove(TInt aIndex); williamr@4: williamr@4: /** williamr@4: * Removes and deletes a link at aIndex from this array. williamr@4: * williamr@4: * @pre aIndex >= 0 && aIndex <= Count() williamr@4: * @post The array count is decreased by one. williamr@4: */ williamr@4: IMPORT_C void Delete(TInt aIndex); williamr@4: williamr@4: /** williamr@4: * Resets the array and destroys the links williamr@4: */ williamr@4: IMPORT_C void ResetAndDestroy(); williamr@4: williamr@4: /** williamr@4: * Resets this array but doesn't destroy links williamr@4: * williamr@4: * @post Count() == 0 williamr@4: */ williamr@4: IMPORT_C void Reset(); williamr@4: williamr@4: /** williamr@4: * Returns the size of the packed link array williamr@4: */ williamr@4: IMPORT_C TInt PackedBufferSize() const; williamr@4: williamr@4: public: // from MVPbkContactLinkArray williamr@4: TInt Count() const; williamr@4: const MVPbkContactLink& At(TInt aIndex) const; williamr@4: TInt Find(const MVPbkContactLink& aLink) const; williamr@4: HBufC8* PackLC() const; williamr@4: const MVPbkStreamable* Streamable() const; williamr@4: williamr@4: private: // implementation williamr@4: CVPbkContactLinkArray(); williamr@4: void ConstructL(); williamr@4: void ConstructL(const TDesC8& aPackedLinks, williamr@4: const MVPbkContactStoreList& aOperations); williamr@4: void ConstructL(RReadStream& aStream, williamr@4: const MVPbkContactStoreList& aOperations); williamr@4: TInt DoCalculatePackedBufferSizeV2() const; williamr@4: void DoFillPackedBufferV2L(RWriteStream& aWriteStream) const; williamr@4: void InternalizeFromBufferL( RReadStream& aReadStream, williamr@4: const MVPbkContactStoreList& aStoreList ); williamr@4: void DoInternalizeFromBufferL( RReadStream& aReadStream, williamr@4: const MVPbkContactStoreList& aStoreList); williamr@4: void DoInternalizeFromBufferV2L(RReadStream& aReadStream, williamr@4: const MVPbkContactStoreList& aStoreList); williamr@4: williamr@4: private: // Data williamr@4: ///Own: contained contact links williamr@4: RPointerArray iLinks; williamr@4: class CStoreUris; williamr@4: /// Own: an internal class for saving link URIs williamr@4: CStoreUris* iStoreUris; williamr@4: /// Ref: a reference to the contact store loader williamr@4: MVPbkContactStoreLoader* iStoreLoader; williamr@4: }; williamr@4: williamr@4: #endif // CVPBKCONTACTLINKARRAY_H williamr@4: williamr@4: // End of file