os/persistentdata/persistentstorage/store/USTOR/UT_DICT.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/store/USTOR/UT_DICT.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,612 @@
     1.4 +// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "UT_STD.H"
    1.20 +#include <s32mem.h>
    1.21 +
    1.22 +#define UNUSED_VAR(a) a = a
    1.23 +
    1.24 +const TInt KStreamDictGranularity=16;
    1.25 +
    1.26 +NONSHARABLE_CLASS(HDictionaryStoreBuf) : public MStreamBuf
    1.27 +	{
    1.28 +public:
    1.29 +	HDictionaryStoreBuf(MStreamBuf& aBuf,CDictionaryStore& aDic,TStreamId aStreamId,TUid aUid);
    1.30 +private:
    1.31 +	// from MStreamBuf
    1.32 +	void DoSynchL(); // only update the stream dic during synch
    1.33 +	// just delegate the rest straight through...
    1.34 +	void DoRelease();
    1.35 +	TInt DoReadL(TAny* aPtr,TInt aMaxLength);
    1.36 +	TInt DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
    1.37 +	TStreamTransfer DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer);
    1.38 +	void DoWriteL(const TAny* aPtr,TInt aLength);
    1.39 +	TInt DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus);
    1.40 +	TStreamTransfer DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer);
    1.41 +	TStreamPos DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset);
    1.42 +private:
    1.43 +	MStreamBuf* iRealBuf; // delegate everything to this
    1.44 +	CDictionaryStore* iDictionary;
    1.45 +	TStreamId iStreamId; // id of the actual stream in the store
    1.46 +	TUid iStreamUid; // Uid to be paired with the stream id in the dic
    1.47 +	};
    1.48 +
    1.49 +NONSHARABLE_CLASS(HNullBuf) : public TMemBuf
    1.50 +	{
    1.51 +public:
    1.52 +	HNullBuf();
    1.53 +private:
    1.54 +	void DoRelease();
    1.55 +	};
    1.56 +
    1.57 +////////////////////////////////////////
    1.58 +// CStreamDictionary
    1.59 +////////////////////////////////////////
    1.60 +
    1.61 +EXPORT_C CStreamDictionary* CStreamDictionary::NewL()
    1.62 +/** Allocates, constructs and returns a pointer to a new stream dictionary.
    1.63 +
    1.64 +The function leaves if it cannot complete successfully.
    1.65 +
    1.66 +@return A pointer to the new stream dictionary object. */
    1.67 +	{
    1.68 +	return new(ELeave) CStreamDictionary;
    1.69 +	}
    1.70 +
    1.71 +EXPORT_C CStreamDictionary* CStreamDictionary::NewLC()
    1.72 +/** Allocates, constructs and returns a pointer to a new stream dictionary, putting 
    1.73 +the pointer onto the cleanup stack.
    1.74 +
    1.75 +Putting the pointer onto the cleanup stack allows the object and allocated 
    1.76 +resources to be cleaned up if a subsequent leave occurs.
    1.77 +
    1.78 +The function leaves if it cannot complete successfully.
    1.79 +
    1.80 +@return A pointer to the new stream dictionary object. */
    1.81 +	{
    1.82 +	CStreamDictionary* dict=NewL();
    1.83 +	CleanupStack::PushL(dict);
    1.84 +	return dict;
    1.85 +	}
    1.86 +
    1.87 +EXPORT_C CStreamDictionary::CStreamDictionary()
    1.88 +	: iArray(KStreamDictGranularity)
    1.89 +	{}
    1.90 +
    1.91 +EXPORT_C CStreamDictionary::~CStreamDictionary()
    1.92 +/** Frees resources owned by the object, prior to its destruction. */
    1.93 +	{}
    1.94 +
    1.95 +EXPORT_C void CStreamDictionary::AssignL(TUid aUid,TStreamId anId)
    1.96 +/** Creates or changes an association between a UID and a stream id.
    1.97 +
    1.98 +If the stream dictionary already contains an entry with the same UID as aUid, 
    1.99 +then the associated stream id in that entry is replaced by anId.
   1.100 +
   1.101 +If anId has the value KNullStreamId, then the function attempts to remove 
   1.102 +the entry whose unique identifier matches aUid.
   1.103 +
   1.104 +@param aUid The UID
   1.105 +@param anId The stream id.
   1.106 +@see CStreamDictionary::Remove() */
   1.107 +	{
   1.108 +	if (anId==KNullStreamId)
   1.109 +		{
   1.110 +		Remove(aUid); // default associated stream is null
   1.111 +		return;
   1.112 +		}
   1.113 +//
   1.114 +	TEntry entry;
   1.115 +	entry.iUid=aUid;
   1.116 +	TKeyArrayFix key(_FOFF(TEntry,iUid),ECmpTUint32);
   1.117 +	TInt i;
   1.118 +	if (iArray.Find(entry,key,i)==0)
   1.119 +		{
   1.120 +		iArray[i].iId=anId;
   1.121 +		return;
   1.122 +		}
   1.123 +//
   1.124 +	__ASSERT_DEBUG(i==iArray.Count(),User::Invariant());
   1.125 +	entry.iId=anId;
   1.126 +	iArray.InsertL(i,entry);
   1.127 +	}
   1.128 +
   1.129 +EXPORT_C void CStreamDictionary::Remove(TUid aUid)
   1.130 +/** Removes an association from the stream dictionary.
   1.131 +
   1.132 +The function searches the stream dictionary for an entry whose UID matches 
   1.133 +aUid. If a match is found, the entry is removed. If no match is found, the 
   1.134 +stream dictionary remains unchanged.
   1.135 +
   1.136 +@param aUid The UID whose matching entry is to be removed from the stream 
   1.137 +dictionary. */
   1.138 +	{
   1.139 +	TEntry entry;
   1.140 +	entry.iUid=aUid;
   1.141 +	TKeyArrayFix key(_FOFF(TEntry,iUid),ECmpTUint32);
   1.142 +	TInt i;
   1.143 +	if (iArray.Find(entry,key,i)==0)
   1.144 +		iArray.Delete(i);
   1.145 +	}
   1.146 +
   1.147 +EXPORT_C TStreamId CStreamDictionary::At(TUid aUid) const
   1.148 +/** Returns the stream id associated with the specified UID.
   1.149 +
   1.150 +@param aUid The UID whose associated stream id is to be returned.
   1.151 +@return The stream id associated with the specified UID.KNullStreamId, if no 
   1.152 +entry in the stream dictionary contains the specified UID. */
   1.153 +	{
   1.154 +	TEntry entry;
   1.155 +	entry.iUid=aUid;
   1.156 +	TKeyArrayFix key(_FOFF(TEntry,iUid),ECmpTUint32);
   1.157 +	TInt i;
   1.158 +	if (iArray.Find(entry,key,i)!=0)
   1.159 +		return KNullStreamId;
   1.160 +//
   1.161 +	return iArray[i].iId;
   1.162 +	}
   1.163 +
   1.164 +EXPORT_C TBool CStreamDictionary::IsNull() const
   1.165 +/** Tests whether the stream dictionary is empty.
   1.166 +
   1.167 +@return True, if the stream dictionary is empty. False if the stream dictionary 
   1.168 +contains at least one entry. */
   1.169 +	{
   1.170 +	return iArray.Count()==0;
   1.171 +	}
   1.172 +
   1.173 +EXPORT_C void CStreamDictionary::ExternalizeL(RWriteStream& aStream) const
   1.174 +/** Externalises an object of this class to a write stream.
   1.175 +
   1.176 +The presence of this function means that the standard templated operator<<() 
   1.177 +can be used to externalise objects of this class.
   1.178 +
   1.179 +@param aStream Stream to which the object should be externalised */
   1.180 +	{
   1.181 +	aStream<<iArray;
   1.182 +	}
   1.183 +
   1.184 +EXPORT_C void CStreamDictionary::InternalizeL(RReadStream& aStream)
   1.185 +/** Internalises an object of this class from a read stream.
   1.186 +
   1.187 +The presence of this function means that the standard templated operator>>() 
   1.188 +can be used to internalise objects of this class.
   1.189 +
   1.190 +Note that this function has assignment semantics. It replaces the old value 
   1.191 +of the object with a new value read from the read stream.
   1.192 +
   1.193 +@param aStream Stream from which the object should be internalised. */
   1.194 +	{
   1.195 +	aStream>>iArray;
   1.196 +	}
   1.197 +
   1.198 +void CStreamDictionary::TEntry::ExternalizeL(RWriteStream& aStream) const
   1.199 +	{
   1.200 +	aStream<<iUid;
   1.201 +	aStream<<iId;
   1.202 +	}
   1.203 +
   1.204 +void CStreamDictionary::TEntry::InternalizeL(RReadStream& aStream)
   1.205 +	{
   1.206 +	aStream>>iUid;
   1.207 +	aStream>>iId;
   1.208 +	}
   1.209 +
   1.210 +
   1.211 +////////////////////////////////////////
   1.212 +// CDictionaryStore
   1.213 +////////////////////////////////////////
   1.214 +
   1.215 +EXPORT_C CDictionaryStore::~CDictionaryStore()
   1.216 +/** Frees resources owned by the object, prior to its destruction. */
   1.217 +	{
   1.218 +	delete iDictionary;
   1.219 +	delete iStore;
   1.220 +	}
   1.221 +
   1.222 +
   1.223 +EXPORT_C void CDictionaryStore::ConstructL()
   1.224 +	{
   1.225 +	iDictionary = CStreamDictionary::NewL();
   1.226 +	RStoreWriteStream stream;
   1.227 +	iStore->SetRootL(stream.CreateLC(*iStore));
   1.228 +	stream<<*iDictionary;
   1.229 +	stream.CommitL();
   1.230 +	CleanupStack::PopAndDestroy(); // dictionary stream
   1.231 +	iStore->CommitL();
   1.232 +	}
   1.233 +
   1.234 +
   1.235 +EXPORT_C void CDictionaryStore::Remove(TUid aUid)
   1.236 +/** Removes the stream associated with the specified UID from the dictionary store.
   1.237 +
   1.238 +If there is no stream associated with the specified UID, then the dictionary 
   1.239 +store remains unchanged.
   1.240 +
   1.241 +The function cannot leave; it returns whether or not it is succesful.
   1.242 +
   1.243 +@param aUid The UID whose associated stream is to be removed from the dictionary 
   1.244 +store. */
   1.245 +	{
   1.246 +	TRAPD(ignore,RemoveL(aUid));
   1.247 +    UNUSED_VAR(ignore);
   1.248 +	}
   1.249 +
   1.250 +
   1.251 +EXPORT_C void CDictionaryStore::RemoveL(TUid aUid)
   1.252 +/** Removes the stream associated with the specified UID from the dictionary store 
   1.253 +and leaves if unsuccessful.
   1.254 +
   1.255 +If there is no stream associated with the specified UID, then the dictionary 
   1.256 +store remains unchanged.
   1.257 +
   1.258 +@param aUid The UID whose associated stream is to be removed from the dictionary 
   1.259 +store. */
   1.260 +	{
   1.261 +	TStreamId id = DictionaryL()->At(aUid);
   1.262 +	if (id!=KNullStreamId)
   1.263 +		{
   1.264 +		DictionaryL()->Remove(aUid);
   1.265 +		iStore->DeleteL(id);
   1.266 +		iDictionaryHasChanged=ETrue;
   1.267 +		}
   1.268 +	}
   1.269 +
   1.270 +
   1.271 +EXPORT_C TInt CDictionaryStore::Commit()
   1.272 +/** Commits changes.
   1.273 +
   1.274 +It establishes a new commit point and then compacts the dictionary store. 
   1.275 +Typically, this is done after changes to new or existing streams are complete 
   1.276 +and the streams themselves have been committed.
   1.277 +
   1.278 +Establishing a new commit point makes changes to the store permanent. Until 
   1.279 +such changes are committed, they can be rolled back, effectively causing the 
   1.280 +store to revert back to its state before the changes were made.
   1.281 +
   1.282 +This ensures that persistent data moves from one consistent state to another 
   1.283 +and guarantees the integrity of persistent store data in the event of failures. 
   1.284 +In particular, if a process terminates or a media failure occurs, the store 
   1.285 +reverts automatically to its state at the last successful commit point.
   1.286 +
   1.287 +@return KErrNone if successful, otherwise another of the system-wide error 
   1.288 +codes. */
   1.289 +	{
   1.290 +	TRAPD(ret,CommitL());
   1.291 +	return ret;
   1.292 +	}
   1.293 +
   1.294 +
   1.295 +EXPORT_C void CDictionaryStore::CommitL()
   1.296 +/** Commits changes and leaves if unsuccessful.
   1.297 +
   1.298 +@see CDictionaryStore::Commit() */
   1.299 +	{
   1.300 +	if (iDictionaryHasChanged)
   1.301 +		{
   1.302 +		// rewrite the root stream
   1.303 +		RStoreWriteStream stream;
   1.304 +		stream.ReplaceLC(*iStore,iStore->Root());
   1.305 +		stream<< *DictionaryL();
   1.306 +		stream.CommitL();
   1.307 +		CleanupStack::PopAndDestroy(); // dictionary stream
   1.308 +		}
   1.309 +	// commit the store
   1.310 +	iStore->CommitL();
   1.311 +	// compact the store, ignoring any failure (commit was good)
   1.312 +	TRAPD(
   1.313 +		ignore,
   1.314 +			{
   1.315 +			if (iStore->ReclaimL() >= KDictionaryCommitThreshold)
   1.316 +				{
   1.317 +				iStore->CompactL();
   1.318 +				}
   1.319 +			iStore->CommitL();
   1.320 +			} );
   1.321 +    UNUSED_VAR(ignore);
   1.322 +	}
   1.323 +
   1.324 +
   1.325 +EXPORT_C void CDictionaryStore::Revert()
   1.326 +/** Rolls the dictionary store back to its state at the last commit point.
   1.327 +
   1.328 +A commit point is set using the Commit() or CommitL() functions.
   1.329 +
   1.330 +The function returns, whether or not it completes successfully.
   1.331 +
   1.332 +@see CDictionaryStore::Commit()
   1.333 +@see CDictionaryStore::CommitL() */
   1.334 +	{
   1.335 +	TRAPD(ignore,RevertL());
   1.336 +    UNUSED_VAR(ignore);
   1.337 +	}
   1.338 +
   1.339 +
   1.340 +EXPORT_C void CDictionaryStore::RevertL()
   1.341 +/** Rolls the dictionary store back to its state at the last commit point and leaves 
   1.342 +if unsuccessful.
   1.343 +
   1.344 +A commit point is set using the Commit() or CommitL() functions.
   1.345 +
   1.346 +@see CDictionaryStore::Commit()
   1.347 +@see CDictionaryStore::CommitL() */
   1.348 +	{
   1.349 +	delete iDictionary;
   1.350 +	iDictionary = NULL;
   1.351 +	iDictionaryHasChanged = EFalse;
   1.352 +	iStore->RevertL();
   1.353 +	}
   1.354 +
   1.355 +
   1.356 +CStreamDictionary* CDictionaryStore::DictionaryL() const
   1.357 +// Returns the handle of the stream dictionary, internalizing it first if necessary
   1.358 +	{
   1.359 +	if (!iDictionary)
   1.360 +		{
   1.361 +		// create a temporary dictionary
   1.362 +		CStreamDictionary* dictionary = CStreamDictionary::NewLC();
   1.363 +		// stream into the dictionary
   1.364 +		RStoreReadStream root;
   1.365 +		root.OpenLC(*iStore,iStore->Root());
   1.366 +		root>> *dictionary;
   1.367 +		root.Close();
   1.368 +		CleanupStack::PopAndDestroy(); // root
   1.369 +		// set iDictionary
   1.370 +		MUTABLE_CAST(CStreamDictionary*&,iDictionary) = dictionary;
   1.371 +		CleanupStack::Pop(); // dictionary
   1.372 +		}
   1.373 +	return iDictionary;
   1.374 +	}
   1.375 +
   1.376 +
   1.377 +EXPORT_C TBool CDictionaryStore::IsNullL() const
   1.378 +/** Tests whether the dictionary stores stream dictionary is empty.
   1.379 +
   1.380 +@return True, if the stream dictionary is empty. False, if the stream dictionary 
   1.381 +contains at least one entry.
   1.382 +@see CStreamDictionary */
   1.383 +	{
   1.384 +	return DictionaryL()->IsNull();
   1.385 +	}
   1.386 +
   1.387 +
   1.388 +EXPORT_C TBool CDictionaryStore::IsPresentL(TUid aUid) const
   1.389 +/** Tests whether the specified UID has an associated stream within this dictionary 
   1.390 +store.
   1.391 +
   1.392 +@param aUid The UID.
   1.393 +@return True, if there is a stream associated with the specified UID in the 
   1.394 +dictionary store; false otherwise.
   1.395 +@see CStreamDictionary */
   1.396 +	{
   1.397 +	return DictionaryL()->At(aUid)!=KNullStreamId;
   1.398 +	}
   1.399 +
   1.400 +
   1.401 +MStreamBuf* CDictionaryStore::GetSourceL(TUid aUid) const
   1.402 +// Opens the stream matching aUid and returns its source.
   1.403 +// If no stream matches aUid an empty stream buf is returned
   1.404 +// Ownership of the source is transfered to the caller.
   1.405 +	{
   1.406 +	// get the id of the stream
   1.407 +	TStreamId id = DictionaryL()->At(aUid);
   1.408 +	// open the stream if it exists, otherwise open a dummy empty stream
   1.409 +	if (id==KNullStreamId)
   1.410 +		return (new(ELeave) HNullBuf);
   1.411 +	else
   1.412 +		{
   1.413 +		// open the stream and steal its source
   1.414 +		RStoreReadStream stream;
   1.415 +		stream.OpenL(*iStore,id);
   1.416 +		return stream.Source();
   1.417 +		}
   1.418 +	}
   1.419 +
   1.420 +
   1.421 +MStreamBuf* CDictionaryStore::GetSinkL(TUid aUid)
   1.422 +// If a stream matches aUid it is replaced ad its sink returned 
   1.423 +// If no stream matches aUid a new stream is created and its sink returned
   1.424 +// Ownership of the sink is transfered to the caller.
   1.425 +	{
   1.426 +	// get the id of the stream
   1.427 +	TStreamId id = DictionaryL()->At(aUid);
   1.428 +	RStoreWriteStream stream;
   1.429 +	if (id!=KNullStreamId)
   1.430 +		//replace the stream
   1.431 +		stream.ReplaceLC(*iStore,id);
   1.432 +	else
   1.433 +		// create a new stream
   1.434 +		id = stream.CreateLC(*iStore);
   1.435 +	// create a dictionary store buffer to hold the incoming data
   1.436 +	MStreamBuf* buf = new(ELeave) HDictionaryStoreBuf(*stream.Sink(),*this,id,aUid);
   1.437 +	CleanupStack::Pop(); // stream;
   1.438 +	return buf;
   1.439 +	}
   1.440 +
   1.441 +
   1.442 +//////////////////////////////////////////////
   1.443 +// RDictionaryReadStream
   1.444 +//////////////////////////////////////////////
   1.445 +
   1.446 +EXPORT_C void RDictionaryReadStream::OpenL(const CDictionaryStore& aDictStore,TUid aUid)
   1.447 +// Open the stream if it exists, otherwise open a dummy empty stream
   1.448 +/** Opens the stream associated with the specified UID in the specified dictionary 
   1.449 +store, and prepares it for reading.
   1.450 +
   1.451 +@param aDictStore The dictionary store containing the stream.
   1.452 +@param aUid The unique identifier associated with the stream to be read. */
   1.453 +	{
   1.454 +	Attach(aDictStore.GetSourceL(aUid));
   1.455 +	}
   1.456 +
   1.457 +
   1.458 +EXPORT_C void RDictionaryReadStream::OpenLC(const CDictionaryStore& aDictStore,TUid aUid)
   1.459 +/** Opens the stream associated with the specified UID in the specified dictionary 
   1.460 +store, prepares it for reading, and puts a a cleanup item onto the cleanup 
   1.461 +stack..
   1.462 +
   1.463 +Placing a cleanup item on the cleanup stack allows allocated resources to 
   1.464 +be cleaned up if a subsequent leave occurs.
   1.465 +
   1.466 +@param aDictStore The dictionary store containing the stream.
   1.467 +@param aUid The unique identifier associated with the stream to be read. */
   1.468 +	{
   1.469 +	OpenL(aDictStore,aUid);
   1.470 +	PushL();
   1.471 +	}
   1.472 +
   1.473 +
   1.474 +//////////////////////////////////////////////
   1.475 +// RDictionaryWriteStream
   1.476 +//////////////////////////////////////////////
   1.477 +
   1.478 +EXPORT_C void RDictionaryWriteStream::AssignL(CDictionaryStore& aDictStore,TUid aUid)
   1.479 +// Replace the stream if it exists, otherwise create a new one
   1.480 +/** Prepares a stream in the specified dictionary store for writing.
   1.481 +
   1.482 +If no stream is associated with the specified UID, then a new stream is created 
   1.483 +and an association is made between the resulting stream id and the specified 
   1.484 +UID. If a stream is currently associated with the specified UID, then this 
   1.485 +existing stream is prepared for replacement.
   1.486 +
   1.487 +@param aDictStore The dictionary store which contains the new or replacement 
   1.488 +stream.
   1.489 +@param aUid The UID associated with the stream.
   1.490 +@see RWriteStream::Release() */
   1.491 +	{
   1.492 +	Attach(aDictStore.GetSinkL(aUid));
   1.493 +	}
   1.494 +
   1.495 +
   1.496 +EXPORT_C void RDictionaryWriteStream::AssignLC(CDictionaryStore& aDictStore,TUid aUid)
   1.497 +/** Prepares a stream in the specified dictionary store for writing, and places 
   1.498 +a cleanup item for this RDictionaryWriteStream object onto the cleanup stack. 
   1.499 +
   1.500 +If no stream is associated with the specified UID, then a new stream is created 
   1.501 +and an association is made between the resulting stream id and the specified 
   1.502 +UID. If a stream is currently associated with the specified UID, then this 
   1.503 +existing stream is prepared for replacement.
   1.504 +
   1.505 +Placing a cleanup item onto the cleanup stack allows allocated resources to 
   1.506 +be cleaned up if a subsequent leave occurs. 
   1.507 +
   1.508 +@param aDictStore The dictionary store which contains the new or replacement 
   1.509 +stream.
   1.510 +@param aUid The UID associated with the stream. */
   1.511 +	{
   1.512 +	AssignL(aDictStore,aUid);
   1.513 +	PushL();
   1.514 +	}
   1.515 +
   1.516 +
   1.517 +//////////////////////////////////////////////
   1.518 +// HDictionaryStoreBuf
   1.519 +//////////////////////////////////////////////
   1.520 +
   1.521 +HDictionaryStoreBuf::HDictionaryStoreBuf(MStreamBuf& aBuf,CDictionaryStore& aDic,TStreamId aStreamId,TUid aUid)
   1.522 +	:iRealBuf(&aBuf),
   1.523 +	iDictionary(&aDic),
   1.524 +	iStreamId(aStreamId),
   1.525 +	iStreamUid(aUid)
   1.526 +	{}
   1.527 +
   1.528 +
   1.529 +void HDictionaryStoreBuf::DoSynchL()
   1.530 +// only update the stream dic during synch - this is when the stream gets added to the store
   1.531 +	{
   1.532 +	CStreamDictionary& dic = *iDictionary->DictionaryL();
   1.533 +	TBool newEntry = (dic.At(iStreamUid)==KNullStreamId);
   1.534 +	if (iRealBuf->SizeL()>0)
   1.535 +		{
   1.536 +		dic.AssignL(iStreamUid,iStreamId);
   1.537 +		TInt ret = iRealBuf->Synch();
   1.538 +		if (ret!=KErrNone)
   1.539 +			{// attempt rollback
   1.540 +			if (newEntry)
   1.541 +				dic.Remove(iStreamUid);
   1.542 +			__LEAVE(ret);
   1.543 +			}
   1.544 +		if (newEntry)
   1.545 +			iDictionary->iDictionaryHasChanged=ETrue;
   1.546 +		}
   1.547 +	else
   1.548 +		{
   1.549 +		iRealBuf->SynchL();
   1.550 +		iDictionary->iStore->Delete(iStreamId);
   1.551 +		iDictionary->Remove(iStreamUid);
   1.552 +		}
   1.553 +	}
   1.554 +
   1.555 +
   1.556 +void HDictionaryStoreBuf::DoRelease()
   1.557 +	{
   1.558 +	iRealBuf->Release();
   1.559 +	delete this;
   1.560 +	}
   1.561 +
   1.562 +
   1.563 +TInt HDictionaryStoreBuf::DoReadL(TAny* aPtr,TInt aMaxLength)
   1.564 +	{
   1.565 +	return iRealBuf->ReadL(aPtr,aMaxLength);
   1.566 +	}
   1.567 +
   1.568 +
   1.569 +TInt HDictionaryStoreBuf::DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
   1.570 +	{
   1.571 +	return iRealBuf->ReadL(aDes,aMaxLength,aStatus);
   1.572 +	}
   1.573 +
   1.574 +
   1.575 +TStreamTransfer HDictionaryStoreBuf::DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer)
   1.576 +	{
   1.577 +	return iRealBuf->ReadL(anInput,aTransfer);
   1.578 +	}
   1.579 +
   1.580 +
   1.581 +void HDictionaryStoreBuf::DoWriteL(const TAny* aPtr,TInt aLength)
   1.582 +	{
   1.583 +	iRealBuf->WriteL(aPtr,aLength);
   1.584 +	}
   1.585 +
   1.586 +
   1.587 +TInt HDictionaryStoreBuf::DoWriteL(const TDesC8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
   1.588 +	{
   1.589 +	return iRealBuf->WriteL(aDes,aMaxLength,aStatus);
   1.590 +	}
   1.591 +
   1.592 +
   1.593 +TStreamTransfer HDictionaryStoreBuf::DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer)
   1.594 +	{
   1.595 +	return iRealBuf->WriteL(anOutput,aTransfer);
   1.596 +	}
   1.597 +
   1.598 +
   1.599 +TStreamPos HDictionaryStoreBuf::DoSeekL(TMark aMark,TStreamLocation aLocation,TInt anOffset)
   1.600 +	{
   1.601 +	return iRealBuf->SeekL(aMark,aLocation,anOffset);
   1.602 +	}
   1.603 +
   1.604 +// class HNullBuf
   1.605 +
   1.606 +HNullBuf::HNullBuf()
   1.607 +	{
   1.608 +	Set(0,0,ERead);
   1.609 +	}
   1.610 +
   1.611 +void HNullBuf::DoRelease()
   1.612 +	{
   1.613 +	delete this;
   1.614 +	}
   1.615 +