1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/app/CVPbkContactLinkArray.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,200 @@
1.4 +/*
1.5 +* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: An array for contact links.
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#ifndef CVPBKCONTACTLINKARRAY_H
1.23 +#define CVPBKCONTACTLINKARRAY_H
1.24 +
1.25 +// INCLUDES
1.26 +#include <e32base.h>
1.27 +#include <mvpbkcontactlinkarray.h>
1.28 +
1.29 +// FORWARD DECLARATIONS
1.30 +class MVPbkContactStoreList;
1.31 +class RWriteStream;
1.32 +class RReadStream;
1.33 +class MVPbkContactStoreLoader;
1.34 +
1.35 +
1.36 +// CLASS DECLARATIONS
1.37 +
1.38 +/**
1.39 + * A read-only array of contact links.
1.40 + * @lib VPbkEng.lib
1.41 + */
1.42 +class CVPbkContactLinkArray :
1.43 + public CBase,
1.44 + public MVPbkContactLinkArray
1.45 + {
1.46 + public: // Constructors and Destructor
1.47 + /**
1.48 + * Creates an empty link array.
1.49 + *
1.50 + * @return A new instance of this class
1.51 + */
1.52 + IMPORT_C static CVPbkContactLinkArray* NewL();
1.53 +
1.54 + /**
1.55 + * Creates an empty link array. Leaves the created array object on
1.56 + * the cleanup stack.
1.57 + *
1.58 + * @return A new instance of this class
1.59 + */
1.60 + IMPORT_C static CVPbkContactLinkArray* NewLC();
1.61 +
1.62 + /**
1.63 + * Creates a link array from a packed descriptor of links.
1.64 + *
1.65 + * @param aPackedLinks a buffer that was created using PackLC
1.66 + * of MVPbkContactLinkArray or MVPbkContactLink
1.67 + * @param aStoreList the list of stores that contain the
1.68 + * stores that links belong.
1.69 + * @return A new instance of this class
1.70 + */
1.71 + IMPORT_C static CVPbkContactLinkArray* NewLC(
1.72 + const TDesC8& aPackedLinks,
1.73 + const MVPbkContactStoreList& aStoreList);
1.74 +
1.75 + /**
1.76 + * Creates a link array from a stream of links.
1.77 + *
1.78 + * @param aStream a stream of contact link that was created
1.79 + * using MVPbkStreamable interface of
1.80 + * MVPbkContactLink
1.81 + * @param aStoreList the list of stores that contain the
1.82 + * stores that links belong.
1.83 + * @return A new instance of this class
1.84 + */
1.85 + IMPORT_C static CVPbkContactLinkArray* NewLC(
1.86 + RReadStream& aStream,
1.87 + const MVPbkContactStoreList& aStoreList);
1.88 +
1.89 + /**
1.90 + * Creates a link array from a stream of links. Uses aLoader
1.91 + * to find and load stores.
1.92 + * aLoader must exist the life time of this object.
1.93 + *
1.94 + * @param aStream a stream of contact link that was created
1.95 + * using MVPbkStreamable interface of
1.96 + * MVPbkContactLink
1.97 + * @param aLoader the contact store loader for internalization.
1.98 + * @return A new instance of this class
1.99 + */
1.100 + static CVPbkContactLinkArray* NewLC(
1.101 + RReadStream& aStream,
1.102 + MVPbkContactStoreLoader& aLoader );
1.103 +
1.104 + /**
1.105 + * Destructor.
1.106 + */
1.107 + ~CVPbkContactLinkArray();
1.108 +
1.109 + public: // interface
1.110 + /**
1.111 + * Appends a link to this array.
1.112 + *
1.113 + * @param aLink the link object to append. This array takes ownership
1.114 + * of the link if append is succesful.
1.115 + * @pre aLink != NULL
1.116 + * @post Array count is increased by one and the link is in the last
1.117 + * element of the array.
1.118 + */
1.119 + IMPORT_C void AppendL(MVPbkContactLink* aLink);
1.120 +
1.121 + /**
1.122 + * Inserts a link to this array.
1.123 + *
1.124 + * @param aLink the link object to insert. This array takes ownership
1.125 + * of the link if insertion is succesful.
1.126 + * @param aIndex position where to insert the link.
1.127 + * @exception KErrNoMemory if out of memory.
1.128 + * @pre aLink != NULL
1.129 + * @pre aIndex >= 0 && aIndex <= Count()
1.130 + * @post Array count is increased by one and the link is in the position
1.131 + * marked by the aIndex element of the array.
1.132 + */
1.133 + IMPORT_C void InsertL(MVPbkContactLink* aLink, TInt aIndex);
1.134 +
1.135 + /**
1.136 + * Removes a link at aIndex from this array.
1.137 + *
1.138 + * @pre aIndex >= 0 && aIndex <= Count()
1.139 + * @post The array count is decreased by one.
1.140 + */
1.141 + IMPORT_C void Remove(TInt aIndex);
1.142 +
1.143 + /**
1.144 + * Removes and deletes a link at aIndex from this array.
1.145 + *
1.146 + * @pre aIndex >= 0 && aIndex <= Count()
1.147 + * @post The array count is decreased by one.
1.148 + */
1.149 + IMPORT_C void Delete(TInt aIndex);
1.150 +
1.151 + /**
1.152 + * Resets the array and destroys the links
1.153 + */
1.154 + IMPORT_C void ResetAndDestroy();
1.155 +
1.156 + /**
1.157 + * Resets this array but doesn't destroy links
1.158 + *
1.159 + * @post Count() == 0
1.160 + */
1.161 + IMPORT_C void Reset();
1.162 +
1.163 + /**
1.164 + * Returns the size of the packed link array
1.165 + */
1.166 + IMPORT_C TInt PackedBufferSize() const;
1.167 +
1.168 + public: // from MVPbkContactLinkArray
1.169 + TInt Count() const;
1.170 + const MVPbkContactLink& At(TInt aIndex) const;
1.171 + TInt Find(const MVPbkContactLink& aLink) const;
1.172 + HBufC8* PackLC() const;
1.173 + const MVPbkStreamable* Streamable() const;
1.174 +
1.175 + private: // implementation
1.176 + CVPbkContactLinkArray();
1.177 + void ConstructL();
1.178 + void ConstructL(const TDesC8& aPackedLinks,
1.179 + const MVPbkContactStoreList& aOperations);
1.180 + void ConstructL(RReadStream& aStream,
1.181 + const MVPbkContactStoreList& aOperations);
1.182 + TInt DoCalculatePackedBufferSizeV2() const;
1.183 + void DoFillPackedBufferV2L(RWriteStream& aWriteStream) const;
1.184 + void InternalizeFromBufferL( RReadStream& aReadStream,
1.185 + const MVPbkContactStoreList& aStoreList );
1.186 + void DoInternalizeFromBufferL( RReadStream& aReadStream,
1.187 + const MVPbkContactStoreList& aStoreList);
1.188 + void DoInternalizeFromBufferV2L(RReadStream& aReadStream,
1.189 + const MVPbkContactStoreList& aStoreList);
1.190 +
1.191 + private: // Data
1.192 + ///Own: contained contact links
1.193 + RPointerArray<MVPbkContactLink> iLinks;
1.194 + class CStoreUris;
1.195 + /// Own: an internal class for saving link URIs
1.196 + CStoreUris* iStoreUris;
1.197 + /// Ref: a reference to the contact store loader
1.198 + MVPbkContactStoreLoader* iStoreLoader;
1.199 + };
1.200 +
1.201 +#endif // CVPBKCONTACTLINKARRAY_H
1.202 +
1.203 +// End of file