smsprotocols/smsstack/smsprot/Src/smspclass0stor.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
child 69 b982c3e940f3
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    16 //
    16 //
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
       
    21 
       
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "smspclass0storTraces.h"
       
    25 #endif
       
    26 
    21 #include "smspclass0stor.h"
    27 #include "smspclass0stor.h"
    22 #include "gsmubuf.h"
    28 #include "gsmubuf.h"
    23 #include "gsmunonieoperations.h"
    29 #include "gsmunonieoperations.h"
    24 
    30 
    25 const TInt KSizeOfPreallocatedFileVersion = sizeof(CPreallocatedFile::TPreAllocatedFileVersion);
    31 const TInt KSizeOfPreallocatedFileVersion = sizeof(CPreallocatedFile::TPreAllocatedFileVersion);
    49 
    55 
    50 @internalComponent
    56 @internalComponent
    51 */
    57 */
    52 CSmsPermanentFileStore* CSmsPermanentFileStore::NewL(RFs& aFs, const TDesC& aFileName, const TUid& aThirdUid)
    58 CSmsPermanentFileStore* CSmsPermanentFileStore::NewL(RFs& aFs, const TDesC& aFileName, const TUid& aThirdUid)
    53 	{
    59 	{
    54 	LOGSMSPROT1("CSmsPermanentFileStore::NewL()");
    60 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_NEWL_1, "CSmsPermanentFileStore::NewL()");
    55 	CSmsPermanentFileStore*  self = new (ELeave) CSmsPermanentFileStore(aFs, aThirdUid);
    61 	CSmsPermanentFileStore*  self = new (ELeave) CSmsPermanentFileStore(aFs, aThirdUid);
    56 	CleanupStack::PushL(self);
    62 	CleanupStack::PushL(self);
    57 	self->ConstructL(aFileName);
    63 	self->ConstructL(aFileName);
    58 	CleanupStack::Pop(self);
    64 	CleanupStack::Pop(self);
    59 
    65 
    60 	return self;
    66 	return self;
    61 	}
    67 	}
    62 
    68 
    63 void CSmsPermanentFileStore::ConstructL(const TDesC& aFileName)
    69 void CSmsPermanentFileStore::ConstructL(const TDesC& aFileName)
    64 	{
    70 	{
    65 	LOGSMSPROT1("CSmsPermanentFileStore::ConstructL()");
    71 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_CONSTRUCTL_1, "CSmsPermanentFileStore::ConstructL()");
    66 	iFileName = aFileName.AllocL();
    72 	iFileName = aFileName.AllocL();
    67 	}
    73 	}
    68 
    74 
    69 /**
    75 /**
    70  *  Constructor.
    76  *  Constructor.
   107 
   113 
   108 @internalComponent
   114 @internalComponent
   109 */
   115 */
   110 void CSmsPermanentFileStore::CreateL()
   116 void CSmsPermanentFileStore::CreateL()
   111 	{
   117 	{
   112 	LOGSMSPROT1("CSmsPermanentFileStore::CreateL()");
   118 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_CREATEL_1, "CSmsPermanentFileStore::CreateL()");
   113 	TUidType uidtype(KPermanentFileStoreLayoutUid,KSARStoreUid,iThirdUid);
   119 	TUidType uidtype(KPermanentFileStoreLayoutUid,KSARStoreUid,iThirdUid);
   114 	iFileStore=CPermanentFileStore::ReplaceL(iFs, iFileName->Des(), EFileShareExclusive|EFileStream|EFileRead|EFileWrite);
   120 	iFileStore=CPermanentFileStore::ReplaceL(iFs, iFileName->Des(), EFileShareExclusive|EFileStream|EFileRead|EFileWrite);
   115 	iFileStore->SetTypeL(uidtype);
   121 	iFileStore->SetTypeL(uidtype);
   116 	iEntryArray.Reset();
   122 	iEntryArray.Reset();
   117 	ExternalizeEntryArrayL();
   123 	ExternalizeEntryArrayL();
   127 
   133 
   128 @internalComponent
   134 @internalComponent
   129 */
   135 */
   130 void CSmsPermanentFileStore::OpenL()
   136 void CSmsPermanentFileStore::OpenL()
   131 	{
   137 	{
   132 	LOGSMSPROT1("CSmsPermanentFileStore::OpenL()");
   138 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_OPENL_1, "CSmsPermanentFileStore::OpenL()");
   133 	iFileStore=CPermanentFileStore::OpenL(iFs,iFileName->Des(),EFileShareExclusive|EFileStream|EFileRead|EFileWrite);
   139 	iFileStore=CPermanentFileStore::OpenL(iFs,iFileName->Des(),EFileShareExclusive|EFileStream|EFileRead|EFileWrite);
   134 	InternalizeEntryArrayL();
   140 	InternalizeEntryArrayL();
   135 	}
   141 	}
   136 
   142 
   137 /**
   143 /**
   139 
   145 
   140 @internalComponent
   146 @internalComponent
   141 */
   147 */
   142 void CSmsPermanentFileStore::Close()
   148 void CSmsPermanentFileStore::Close()
   143 	{
   149 	{
   144 	LOGSMSPROT1("CSmsPermanentFileStore::Close()");
   150 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_CLOSE_1, "CSmsPermanentFileStore::Close()");
   145 	delete iFileStore;
   151 	delete iFileStore;
   146 	iFileStore = NULL;
   152 	iFileStore = NULL;
   147 	iEntryArray.Reset();
   153 	iEntryArray.Reset();
   148 	}
   154 	}
   149 
   155 
   163 */
   169 */
   164 void CSmsPermanentFileStore::CleanupEntriesWithCompactL(const CArrayFix<TSmsPreAllocatedFileStoreReassemblyEntry>& aEntryArray)
   170 void CSmsPermanentFileStore::CleanupEntriesWithCompactL(const CArrayFix<TSmsPreAllocatedFileStoreReassemblyEntry>& aEntryArray)
   165 	{
   171 	{
   166     // Ignore in code coverage - a previous CleanupEntries would need to have failed with KErrDiskFull
   172     // Ignore in code coverage - a previous CleanupEntries would need to have failed with KErrDiskFull
   167 	BULLSEYE_OFF
   173 	BULLSEYE_OFF
   168 	LOGSMSPROT1("CSmsPermanentFileStore::CleanupEntriesWithCompactL()");
   174 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_CLEANUPENTRIESWITHCOMPACTL_1, "CSmsPermanentFileStore::CleanupEntriesWithCompactL()");
   169 
   175 
   170 	iCompact = ETrue;
   176 	iCompact = ETrue;
   171 	CleanupEntriesL(aEntryArray);
   177 	CleanupEntriesL(aEntryArray);
   172 	BULLSEYE_RESTORE	
   178 	BULLSEYE_RESTORE	
   173 	}
   179 	}
   185 
   191 
   186 @internalComponent
   192 @internalComponent
   187 */
   193 */
   188 void CSmsPermanentFileStore::CleanupEntriesL(const CArrayFix<TSmsPreAllocatedFileStoreReassemblyEntry>& aEntryArray)
   194 void CSmsPermanentFileStore::CleanupEntriesL(const CArrayFix<TSmsPreAllocatedFileStoreReassemblyEntry>& aEntryArray)
   189 	{
   195 	{
   190 	LOGSMSPROT1("CSmsPermanentFileStore::CleanupEntriesL()");
   196 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_CLEANUPENTRIESL_1, "CSmsPermanentFileStore::CleanupEntriesL()");
   191 
   197 
   192 	TInt reassemblyCount = iEntryArray.Count();
   198 	TInt reassemblyCount = iEntryArray.Count();
   193 	TInt index, index2;
   199 	TInt index, index2;
   194 
   200 
   195 	for (index = 0;  index < reassemblyCount;  index++)
   201 	for (index = 0;  index < reassemblyCount;  index++)
   255 
   261 
   256 @internalComponent
   262 @internalComponent
   257 */
   263 */
   258 void CSmsPermanentFileStore::InternalizeEntryArrayL()
   264 void CSmsPermanentFileStore::InternalizeEntryArrayL()
   259 	{
   265 	{
   260 	LOGSMSPROT1("CSmsPermanentFileStore::InternalizeEntryArrayL()");
   266 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_INTERNALIZEENTRYARRAYL_1, "CSmsPermanentFileStore::InternalizeEntryArrayL()");
   261 
   267 
   262 	iEntryArray.Reset();
   268 	iEntryArray.Reset();
   263 	TStreamId headerid=iFileStore->Root();
   269 	TStreamId headerid=iFileStore->Root();
   264 	RStoreReadStream stream;
   270 	RStoreReadStream stream;
   265 	stream.OpenLC(*iFileStore,headerid);
   271 	stream.OpenLC(*iFileStore,headerid);
   278 
   284 
   279 @internalComponent
   285 @internalComponent
   280 */
   286 */
   281 void CSmsPermanentFileStore::ExternalizeEntryArrayL()
   287 void CSmsPermanentFileStore::ExternalizeEntryArrayL()
   282 	{
   288 	{
   283 	LOGSMSPROT4("CSmsPermanentFileStore::ExternalizeEntryArrayL(): this=0x%08X count=%d headerid=%d]",
   289 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_EXTERNALIZEENTRYARRAYL_1, "CSmsPermanentFileStore::ExternalizeEntryArrayL(): this=0x%08X count=%d headerid=%u]",(TUint) this, iEntryArray.Count(), (TUint)iFileStore->Root().Value());
   284 			 this, iEntryArray.Count(), iFileStore->Root().Value());
       
   285 
   290 
   286 	TStreamId headerid=iFileStore->Root();
   291 	TStreamId headerid=iFileStore->Root();
   287 	RStoreWriteStream stream;
   292 	RStoreWriteStream stream;
   288 	if (headerid==KNullStreamId)
   293 	if (headerid==KNullStreamId)
   289 		{
   294 		{
   328 
   333 
   329 @internalComponent
   334 @internalComponent
   330 */
   335 */
   331 void CSmsPermanentFileStore::AddNewMessageL(TInt& aIndex, CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms)
   336 void CSmsPermanentFileStore::AddNewMessageL(TInt& aIndex, CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms)
   332 	{
   337 	{
   333 	LOGSMSPROT1("CSmsPermanentFileStore::AddNewMessageL");
   338 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_ADDNEWMESSAGEL_1, "CSmsPermanentFileStore::AddNewMessageL");
   334 
   339 
   335 	CArrayFix<TInt>* indexArray=new(ELeave) CArrayFixFlat<TInt>(KFlatArrayGranularity);
   340 	CArrayFix<TInt>* indexArray=new(ELeave) CArrayFixFlat<TInt>(KFlatArrayGranularity);
   336 	CleanupStack::PushL(indexArray);
   341 	CleanupStack::PushL(indexArray);
   337 	CArrayFixFlat<TGsmSms>* smsArray=new(ELeave) CArrayFixFlat<TGsmSms>(KFlatArrayGranularity);
   342 	CArrayFixFlat<TGsmSms>* smsArray=new(ELeave) CArrayFixFlat<TGsmSms>(KFlatArrayGranularity);
   338 	CleanupStack::PushL(smsArray);
   343 	CleanupStack::PushL(smsArray);
   369 
   374 
   370 @internalComponent
   375 @internalComponent
   371 */
   376 */
   372 void CSmsPermanentFileStore::UpdateExistingMessageL(TInt aIndex, const CSmsMessage& aSmsMessage,const CArrayFix<TInt>& aIndexArray,const CArrayFix<TGsmSms>& aSmsArray)
   377 void CSmsPermanentFileStore::UpdateExistingMessageL(TInt aIndex, const CSmsMessage& aSmsMessage,const CArrayFix<TInt>& aIndexArray,const CArrayFix<TGsmSms>& aSmsArray)
   373 	{
   378 	{
   374 	LOGSMSPROT1("CSmsPermanentFileStore::UpdateExistingMessageL()");
   379 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_UPDATEEXISTINGMESSAGEL_1, "CSmsPermanentFileStore::UpdateExistingMessageL()");
   375 	TStreamId  streamid = iEntryArray[aIndex].DataStreamId();
   380 	TStreamId  streamid = iEntryArray[aIndex].DataStreamId();
   376 	ExternalizeEntryL(streamid, aSmsMessage, aIndexArray, aSmsArray);
   381 	ExternalizeEntryL(streamid, aSmsMessage, aIndexArray, aSmsArray);
   377 	TSmsReassemblyEntry entry;
   382 	TSmsReassemblyEntry entry;
   378 	CReassemblyStoreUtility::PopulateEntry(entry, aSmsMessage, aSmsArray.Count());
   383 	CReassemblyStoreUtility::PopulateEntry(entry, aSmsMessage, aSmsArray.Count());
   379 	entry.SetDataStreamId(streamid);
   384 	entry.SetDataStreamId(streamid);
   390 @internalComponent
   395 @internalComponent
   391 */
   396 */
   392 void CSmsPermanentFileStore::MatchEntryToExistingMessage(const TReassemblyEntry& aEntry,
   397 void CSmsPermanentFileStore::MatchEntryToExistingMessage(const TReassemblyEntry& aEntry,
   393 													TInt& aIndex)
   398 													TInt& aIndex)
   394 	{
   399 	{
   395 	LOGSMSPROT1("CSmsPermanentFileStore::MatchEntryToExistingMessage()");
   400 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_MATCHENTRYTOEXISTINGMESSAGE_1, "CSmsPermanentFileStore::MatchEntryToExistingMessage()");
   396 
   401 
   397 	aIndex = KErrNotFound;
   402 	aIndex = KErrNotFound;
   398 
   403 
   399 	//
   404 	//
   400 	// Search the reassembly store for a matching entry...
   405 	// Search the reassembly store for a matching entry...
   416 			aIndex = index;
   421 			aIndex = index;
   417 			break;
   422 			break;
   418 			}
   423 			}
   419 		}
   424 		}
   420 
   425 
   421 	LOGSMSPROT2("CSmsPermanentFileStore::MatchEntryToExistingMessage(): aIndex=%d", aIndex);
   426 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_MATCHENTRYTOEXISTINGMESSAGE_2, "CSmsPermanentFileStore::MatchEntryToExistingMessage(): aIndex=%d", aIndex);
   422 	}
   427 	}
   423 
   428 
   424 /*
   429 /*
   425 It updates the log server id of the message.
   430 It updates the log server id of the message.
   426 
   431 
   429 
   434 
   430 @internalComponent
   435 @internalComponent
   431 */
   436 */
   432 void CSmsPermanentFileStore::UpdateLogServerIdL(TInt& aIndex, TLogId aLogServerId)
   437 void CSmsPermanentFileStore::UpdateLogServerIdL(TInt& aIndex, TLogId aLogServerId)
   433 	{
   438 	{
   434 	LOGSMSPROT1("CSmsPermanentFileStore::UpdateLogServerIdL");
   439 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_UPDATELOGSERVERIDL_1, "CSmsPermanentFileStore::UpdateLogServerIdL");
   435 
   440 
   436 	TSmsReassemblyEntry entry;
   441 	TSmsReassemblyEntry entry;
   437 	entry = iEntryArray[aIndex];
   442 	entry = iEntryArray[aIndex];
   438 
   443 
   439 	if (entry.LogServerId() != aLogServerId)
   444 	if (entry.LogServerId() != aLogServerId)
   451 
   456 
   452 @internalComponent
   457 @internalComponent
   453 */
   458 */
   454 void CSmsPermanentFileStore::SetPassedToClientL(TInt aIndex, TBool aBool)
   459 void CSmsPermanentFileStore::SetPassedToClientL(TInt aIndex, TBool aBool)
   455 	{
   460 	{
   456 	LOGSMSPROT2("CSmsPermanentFileStore::SetPassedToClientL(): aIndex=%d", aIndex);
   461 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_SETPASSEDTOCLIENTL_1, "CSmsPermanentFileStore::SetPassedToClientL(): aIndex=%d", aIndex);
   457 
   462 
   458 	TSmsReassemblyEntry entry;
   463 	TSmsReassemblyEntry entry;
   459 	entry = iEntryArray[aIndex];
   464 	entry = iEntryArray[aIndex];
   460 
   465 
   461 	if (entry.PassedToClient() != aBool)
   466 	if (entry.PassedToClient() != aBool)
   486 
   491 
   487 @internalComponent
   492 @internalComponent
   488 */
   493 */
   489 void CSmsPermanentFileStore::ChangeEntryL(TInt aIndex,const TSmsReassemblyEntry& aNewEntry)
   494 void CSmsPermanentFileStore::ChangeEntryL(TInt aIndex,const TSmsReassemblyEntry& aNewEntry)
   490 	{
   495 	{
   491 	LOGSMSPROT2("CSmsPermanentFileStore::ChangeEntryL(): aIndex=%d", aIndex);
   496 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_CHANGEENTRYL_1, "CSmsPermanentFileStore::ChangeEntryL(): aIndex=%d", aIndex);
   492 
   497 
   493 	iEntryArray[aIndex].SetIsDeleted(ETrue);
   498 	iEntryArray[aIndex].SetIsDeleted(ETrue);
   494 	iEntryArray.InsertL(aIndex,aNewEntry);
   499 	iEntryArray.InsertL(aIndex,aNewEntry);
   495 	iEntryArray[aIndex].SetIsAdded(ETrue);
   500 	iEntryArray[aIndex].SetIsAdded(ETrue);
   496 	}
   501 	}
   518 
   523 
   519 @internalComponent
   524 @internalComponent
   520 */
   525 */
   521 void CSmsPermanentFileStore::ExternalizeEntryL(TStreamId& aStreamId,const CSmsMessage& aSmsMessage,const CArrayFix<TInt>& aIndexArray,const CArrayFix<TGsmSms>& aSmsArray)
   526 void CSmsPermanentFileStore::ExternalizeEntryL(TStreamId& aStreamId,const CSmsMessage& aSmsMessage,const CArrayFix<TInt>& aIndexArray,const CArrayFix<TGsmSms>& aSmsArray)
   522 	{
   527 	{
   523 	LOGSMSPROT2("CSmsPermanentFileStore::ExternalizeEntryL Start [sid=%d]", aStreamId.Value());
   528 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_EXTERNALIZEENTRYL_1, "CSmsPermanentFileStore::ExternalizeEntryL Start [sid=%d]", aStreamId.Value());
   524 
   529 
   525 	RStoreWriteStream writestream;
   530 	RStoreWriteStream writestream;
   526 	if (aStreamId==KNullStreamId)
   531 	if (aStreamId==KNullStreamId)
   527 		aStreamId=writestream.CreateLC(*iFileStore);
   532 		aStreamId=writestream.CreateLC(*iFileStore);
   528 	else
   533 	else
   542 		writestream << pdu;
   547 		writestream << pdu;
   543 		}
   548 		}
   544 	writestream.CommitL();
   549 	writestream.CommitL();
   545 	CleanupStack::PopAndDestroy();
   550 	CleanupStack::PopAndDestroy();
   546 
   551 
   547 	LOGSMSPROT2("CClass0PermanentFileStore::ExternalizeEntryL End [count=%d]", count);
   552 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_EXTERNALIZEENTRYL_2, "CClass0PermanentFileStore::ExternalizeEntryL End [count=%d]", count);
   548 	}
   553 	}
   549 
   554 
   550 /*
   555 /*
   551 It internalizes(reads) the entry from permanent store file.
   556 It internalizes(reads) the entry from permanent store file.
   552 
   557 
   558 @internalComponent
   563 @internalComponent
   559 */
   564 */
   560 void CSmsPermanentFileStore::InternalizeEntryL(const TInt aIndex, CSmsMessage& aSmsMessage, CArrayFix<TInt>& aIndexArray, CArrayFix<TGsmSms>& aSmsArray)
   565 void CSmsPermanentFileStore::InternalizeEntryL(const TInt aIndex, CSmsMessage& aSmsMessage, CArrayFix<TInt>& aIndexArray, CArrayFix<TGsmSms>& aSmsArray)
   561 	{
   566 	{
   562 	TSmsReassemblyEntry&  entry = iEntryArray[aIndex];
   567 	TSmsReassemblyEntry&  entry = iEntryArray[aIndex];
   563 	LOGSMSPROT2("CSmsPermanentFileStore::InternalizeEntryL Start [sid=%d]", entry.DataStreamId().Value());
   568 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_INTERNALIZEENTRYL_1, "CSmsPermanentFileStore::InternalizeEntryL Start [sid=%d]", entry.DataStreamId().Value());
   564 	RStoreReadStream readstream;
   569 	RStoreReadStream readstream;
   565 	readstream.OpenLC(*iFileStore, entry.DataStreamId());
   570 	readstream.OpenLC(*iFileStore, entry.DataStreamId());
   566 	readstream >> aSmsMessage;
   571 	readstream >> aSmsMessage;
   567 	TInt count=readstream.ReadInt32L();
   572 	TInt count=readstream.ReadInt32L();
   568 	TInt i;
   573 	TInt i;
   587 	CleanupStack::PopAndDestroy();
   592 	CleanupStack::PopAndDestroy();
   588 	//Set other properties of CSmsMessage
   593 	//Set other properties of CSmsMessage
   589 	aSmsMessage.SetStorage(entry.Storage());
   594 	aSmsMessage.SetStorage(entry.Storage());
   590 	aSmsMessage.SetLogServerId(entry.LogServerId());
   595 	aSmsMessage.SetLogServerId(entry.LogServerId());
   591 	aSmsMessage.SetTime(entry.Time());
   596 	aSmsMessage.SetTime(entry.Time());
   592 	LOGSMSPROT2("CSmsPermanentFileStore::InternalizeEntryL End [count=%d]", count);
   597 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_INTERNALIZEENTRYL_2, "CSmsPermanentFileStore::InternalizeEntryL End [count=%d]", count);
   593 	}
   598 	}
   594 
   599 
   595 /*
   600 /*
   596 It removes the PDUs from permanent store file.
   601 It removes the PDUs from permanent store file.
   597 This function is needed because after forwarding the incomplete message
   602 This function is needed because after forwarding the incomplete message
   605 
   610 
   606 @internalComponent
   611 @internalComponent
   607 */
   612 */
   608 void CSmsPermanentFileStore::RemovePDUsL(TInt aIndex, TInt aStartPos, TInt aEndPos)
   613 void CSmsPermanentFileStore::RemovePDUsL(TInt aIndex, TInt aStartPos, TInt aEndPos)
   609 	{
   614 	{
   610 	LOGSMSPROT1("CSmsPermanentFileStore::RemovePDUsL");
   615 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_REMOVEPDUSL_1, "CSmsPermanentFileStore::RemovePDUsL");
   611 
   616 
   612 	CSmsBuffer*  buffer = CSmsBuffer::NewL();
   617 	CSmsBuffer*  buffer = CSmsBuffer::NewL();
   613 	CSmsMessage*  smsMessage = CSmsMessage::NewL(iFs, CSmsPDU::ESmsDeliver, buffer);
   618 	CSmsMessage*  smsMessage = CSmsMessage::NewL(iFs, CSmsPDU::ESmsDeliver, buffer);
   614 	CleanupStack::PushL(smsMessage);
   619 	CleanupStack::PushL(smsMessage);
   615 
   620 
   662  *  invalid.
   667  *  invalid.
   663  *  @capability None
   668  *  @capability None
   664  */
   669  */
   665 void CSmsPermanentFileStore::BeginTransactionL()
   670 void CSmsPermanentFileStore::BeginTransactionL()
   666 	{
   671 	{
   667     LOGSMSPROT4("CSmsPermanentFileStore::BeginTransactionL [this=0x%08X iInTransaction=%d iFileStore=0x%08X]", this, iInTransaction, iFileStore);
   672     OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_BEGINTRANSACTIONL_1, "CSmsPermanentFileStore::BeginTransactionL [this=0x%08X iInTransaction=%d iFileStore=0x%08X]", (TUint)this, iInTransaction, (TUint)iFileStore);
   668 
   673 
   669 	if (iFileStore == NULL || iInTransaction)
   674 	if (iFileStore == NULL || iInTransaction)
   670 		{
   675 		{
   671 		LOGSMSPROT1("WARNING CSmsPermanentFileStore::BeginTransactionL leaving with KErrAccessDenied");
   676 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_BEGINTRANSACTIONL_2, "WARNING CSmsPermanentFileStore::BeginTransactionL leaving with KErrAccessDenied");
   672 		User::Leave(KErrAccessDenied);
   677 		User::Leave(KErrAccessDenied);
   673 		}
   678 		}
   674 
   679 
   675 	iInTransaction = ETrue;
   680 	iInTransaction = ETrue;
   676 	} // CSmsPermanentFileStore::BeginTransactionL
   681 	} // CSmsPermanentFileStore::BeginTransactionL
   678 /**
   683 /**
   679  *  It reverts the transaction.
   684  *  It reverts the transaction.
   680  */
   685  */
   681 void CSmsPermanentFileStore::Revert()
   686 void CSmsPermanentFileStore::Revert()
   682 	{
   687 	{
   683 	LOGSMSPROT3("CSmsPermanentFileStore::Revert(): this=0x%08X, iInTransaction=%d",
   688 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_REVERT_1, "CSmsPermanentFileStore::Revert(): this=0x%08X, iInTransaction=%d",(TUint)this, iInTransaction);
   684     		 this, iInTransaction);
       
   685 
   689 
   686 	iFileStore->Revert();
   690 	iFileStore->Revert();
   687 	iInTransaction = EFalse;
   691 	iInTransaction = EFalse;
   688 	ReinstateDeletedEntries();
   692 	ReinstateDeletedEntries();
   689 	} // CSmsPermanentFileStore::Revert
   693 	} // CSmsPermanentFileStore::Revert
   691 /**
   695 /**
   692  *  It commits the transaction. Then it compact the permanent store file.
   696  *  It commits the transaction. Then it compact the permanent store file.
   693  */
   697  */
   694 void CSmsPermanentFileStore::DoCommitAndCompactL()
   698 void CSmsPermanentFileStore::DoCommitAndCompactL()
   695 	{
   699 	{
   696 	LOGSMSPROT1("CSmsPermanentFileStore::DoCommitAndCompactL()");
   700 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_DOCOMMITANDCOMPACTL_1, "CSmsPermanentFileStore::DoCommitAndCompactL()");
   697 
   701 
   698 	LOGSMSPROTTIMESTAMP();
   702 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_DEBUG) 
       
   703     TBuf<40> timestamp;
       
   704     SmsTimeStampL(timestamp);
       
   705     OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS,CSMSPERMANENTFILESTORE_DOCOMMITANDCOMPACTL_2, "%S",timestamp);
       
   706 #endif
   699 	iFileStore->CommitL();
   707 	iFileStore->CommitL();
   700 	LOGSMSPROTTIMESTAMP();
   708 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_DEBUG) 
       
   709     SmsTimeStampL(timestamp);
       
   710     OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS,CSMSPERMANENTFILESTORE_DOCOMMITANDCOMPACTL_3, "%S",timestamp);
       
   711 #endif
   701 
   712 
   702 	iCommitCount--;
   713 	iCommitCount--;
   703 	if ((iCommitCount < 0) || (iCompact))
   714 	if ((iCommitCount < 0) || (iCompact))
   704 		{
   715 		{
   705 		iCommitCount = KNumStoreCommitsBeforeCompaction;
   716 		iCommitCount = KNumStoreCommitsBeforeCompaction;
   712 /**
   723 /**
   713  *  It commits the transaction.
   724  *  It commits the transaction.
   714  */
   725  */
   715 void CSmsPermanentFileStore::CommitTransactionL()
   726 void CSmsPermanentFileStore::CommitTransactionL()
   716 	{
   727 	{
   717 	LOGSMSPROT4("CSmsPermanentFileStore::CommitTransactionL(): this=0x%08X iInTransaction=%d iFileStore=0x%08X",
   728 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_COMMITTRANSACTIONL_1, "CSmsPermanentFileStore::CommitTransactionL(): this=0x%08X iInTransaction=%d iFileStore=0x%08X",(TUint)this, iInTransaction, (TUint)iFileStore);
   718     		 this, iInTransaction, iFileStore);
       
   719 
   729 
   720 	ExternalizeEntryArrayL();
   730 	ExternalizeEntryArrayL();
   721 
   731 
   722 #ifdef _SMS_LOGGING_ENABLED
   732 #ifdef OST_TRACE_COMPLIER_IN_USE
   723 	TRAPD(err, DoCommitAndCompactL());
   733 	TRAPD(err, DoCommitAndCompactL());
   724 	if (err != KErrNone)
   734 	if (err != KErrNone)
   725 		{
   735 		{
   726 		LOGGSMU2("WARNING! could not CommitL/CompactL due to %d", err);
   736 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_COMMITTRANSACTIONL_2, "WARNING! could not CommitL/CompactL due to %d", err);
   727 		User::Leave(err);
   737 		User::Leave(err);
   728 		}
   738 		}
   729 #else
   739 #else
   730 	DoCommitAndCompactL();
   740 	DoCommitAndCompactL();
   731 #endif
   741 #endif
   738  *  It removes the deleted entries from entry arry.
   748  *  It removes the deleted entries from entry arry.
   739  *	This function is called after commit.
   749  *	This function is called after commit.
   740  */
   750  */
   741 void CSmsPermanentFileStore::RemoveDeletedEntries()
   751 void CSmsPermanentFileStore::RemoveDeletedEntries()
   742 	{
   752 	{
   743 	LOGSMSPROT1("CSmsPermanentFileStore::RemoveDeletedEntries()");
   753 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_REMOVEDELETEDENTRIES_1, "CSmsPermanentFileStore::RemoveDeletedEntries()");
   744 
   754 
   745 	TInt count=iEntryArray.Count();
   755 	TInt count=iEntryArray.Count();
   746 	while (count--)
   756 	while (count--)
   747 		{
   757 		{
   748 		TSmsReassemblyEntry& entry = iEntryArray[count];
   758 		TSmsReassemblyEntry& entry = iEntryArray[count];
   762  *  It reinstate the deleted/added entries from entry arry.
   772  *  It reinstate the deleted/added entries from entry arry.
   763  *	This function is called after revert operation.
   773  *	This function is called after revert operation.
   764  */
   774  */
   765 void CSmsPermanentFileStore::ReinstateDeletedEntries()
   775 void CSmsPermanentFileStore::ReinstateDeletedEntries()
   766 	{
   776 	{
   767 	LOGSMSPROT1("CSmsPermanentFileStore::ReinstateDeletedEntries()");
   777 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSPERMANENTFILESTORE_REINSTATEDELETEDENTRIES_1, "CSmsPermanentFileStore::ReinstateDeletedEntries()");
   768 
   778 
   769 	TInt count=iEntryArray.Count();
   779 	TInt count=iEntryArray.Count();
   770 	while (count--)
   780 	while (count--)
   771 		{
   781 		{
   772 		TSmsReassemblyEntry& entry = iEntryArray[count];
   782 		TSmsReassemblyEntry& entry = iEntryArray[count];
   847 
   857 
   848 @internalComponent
   858 @internalComponent
   849 */
   859 */
   850 CPreallocatedFile* CPreallocatedFile::NewL(RFs& aFs, const TDesC& aFileName, TInt aMaxClass0Msg, TInt aMaxPDUSeg, TPreAllocatedFileVersion aVersion)
   860 CPreallocatedFile* CPreallocatedFile::NewL(RFs& aFs, const TDesC& aFileName, TInt aMaxClass0Msg, TInt aMaxPDUSeg, TPreAllocatedFileVersion aVersion)
   851 	{
   861 	{
   852 	LOGSMSPROT1("CPreallocatedFile::NewL()");
   862 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_NEWL_1, "CPreallocatedFile::NewL()");
   853 	CPreallocatedFile*  self = new (ELeave) CPreallocatedFile(aFs, aMaxClass0Msg, aMaxPDUSeg, aVersion);
   863 	CPreallocatedFile*  self = new (ELeave) CPreallocatedFile(aFs, aMaxClass0Msg, aMaxPDUSeg, aVersion);
   854 	CleanupStack::PushL(self);
   864 	CleanupStack::PushL(self);
   855 	self->ConstructL(aFileName);
   865 	self->ConstructL(aFileName);
   856 	CleanupStack::Pop(self);
   866 	CleanupStack::Pop(self);
   857 
   867 
   858 	return self;
   868 	return self;
   859 	}
   869 	}
   860 
   870 
   861 void CPreallocatedFile::ConstructL(const TDesC& aFileName)
   871 void CPreallocatedFile::ConstructL(const TDesC& aFileName)
   862 	{
   872 	{
   863 	LOGSMSPROT1("CPreallocatedFile::ConstructL()");
   873 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_CONSTRUCTL_1, "CPreallocatedFile::ConstructL()");
   864 	iFileName = aFileName.AllocL();
   874 	iFileName = aFileName.AllocL();
   865 	}
   875 	}
   866 
   876 
   867 /**
   877 /**
   868  *  Constructor.
   878  *  Constructor.
   912 
   922 
   913 @internalComponent
   923 @internalComponent
   914 */
   924 */
   915 TBool CPreallocatedFile::IsFileOK()
   925 TBool CPreallocatedFile::IsFileOK()
   916 	{
   926 	{
   917 	LOGSMSPROT1("CPreallocatedFile::IsFileOK()");
   927 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_ISFILEOK_1, "CPreallocatedFile::IsFileOK()");
   918 
   928 
   919 	TEntry entry;
   929 	TEntry entry;
   920 	//  Check file exists
   930 	//  Check file exists
   921 	TInt ret=iFs.Entry(iFileName->Des(), entry);
   931 	TInt ret=iFs.Entry(iFileName->Des(), entry);
   922 	// Check the size of file, if size does not match then assume that file
   932 	// Check the size of file, if size does not match then assume that file
   941 
   951 
   942 @internalComponent
   952 @internalComponent
   943 */
   953 */
   944 void CPreallocatedFile::CreateL()
   954 void CPreallocatedFile::CreateL()
   945 	{
   955 	{
   946 	LOGSMSPROT1("CPreallocatedFile::CreateL");
   956 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_CREATEL_1, "CPreallocatedFile::CreateL");
   947 
   957 
   948 	User::LeaveIfError(iFile.Replace(iFs, iFileName->Des(), EFileWrite));
   958 	User::LeaveIfError(iFile.Replace(iFs, iFileName->Des(), EFileWrite));
   949 	User::LeaveIfError(iFile.SetSize(iSizeOfFile));
   959 	User::LeaveIfError(iFile.SetSize(iSizeOfFile));
   950 	iFile.Flush();
   960 	iFile.Flush();
   951 
   961 
  1096 
  1106 
  1097 @internalComponent
  1107 @internalComponent
  1098 */
  1108 */
  1099 void CPreallocatedFile::AddNewMessageL(TInt& aIndex, CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms)
  1109 void CPreallocatedFile::AddNewMessageL(TInt& aIndex, CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms)
  1100 	{
  1110 	{
  1101 	LOGSMSPROT1("CPreallocatedFile::AddNewMessageL");
  1111 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_ADDNEWMESSAGEL_1, "CPreallocatedFile::AddNewMessageL");
  1102 	//Gets the next free slot where the message will be stored.
  1112 	//Gets the next free slot where the message will be stored.
  1103 	TInt nextFreeSlot = GetFreeContainer();
  1113 	TInt nextFreeSlot = GetFreeContainer();
  1104 	TInt pduIndex=aSmsMessage.IsDecoded()? 0: aSmsMessage.SmsPDU().ConcatenatedMessagePDUIndex();
  1114 	TInt pduIndex=aSmsMessage.IsDecoded()? 0: aSmsMessage.SmsPDU().ConcatenatedMessagePDUIndex();
  1105 	if (aSmsMessage.Storage() == CSmsMessage::ESmsSIMStorage  ||
  1115 	if (aSmsMessage.Storage() == CSmsMessage::ESmsSIMStorage  ||
  1106 		aSmsMessage.Storage() == CSmsMessage::ESmsCombinedStorage)
  1116 		aSmsMessage.Storage() == CSmsMessage::ESmsCombinedStorage)
  1145 
  1155 
  1146 @internalComponent
  1156 @internalComponent
  1147 */
  1157 */
  1148 void CPreallocatedFile::UpdateExistingMessageL(TInt aIndex, const CSmsMessage& aSmsMessage, TInt aPduIndex, const TGsmSms& aSms)
  1158 void CPreallocatedFile::UpdateExistingMessageL(TInt aIndex, const CSmsMessage& aSmsMessage, TInt aPduIndex, const TGsmSms& aSms)
  1149 	{
  1159 	{
  1150 	LOGSMSPROT1("CPreallocatedFile::UpdateExistingMessageL()");
  1160 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_UPDATEEXISTINGMESSAGEL_1, "CPreallocatedFile::UpdateExistingMessageL()");
  1151 	TInt preAllocatedStorageId = iEntryArray[aIndex].PreAllocatedStorageId();
  1161 	TInt preAllocatedStorageId = iEntryArray[aIndex].PreAllocatedStorageId();
  1152 	if (preAllocatedStorageId == KErrNotFound)
  1162 	if (preAllocatedStorageId == KErrNotFound)
  1153 		{
  1163 		{
  1154 		/*
  1164 		/*
  1155 		This condition arises when part of message is stored in permanent store file & 
  1165 		This condition arises when part of message is stored in permanent store file & 
  1193 @internalComponent
  1203 @internalComponent
  1194 */
  1204 */
  1195 void CPreallocatedFile::MatchEntryToExistingMessage(const TReassemblyEntry& aEntry,
  1205 void CPreallocatedFile::MatchEntryToExistingMessage(const TReassemblyEntry& aEntry,
  1196 													TInt& aIndex)
  1206 													TInt& aIndex)
  1197 	{
  1207 	{
  1198 	LOGSMSPROT1("CPreallocatedFile::MatchEntryToExistingMessage()");
  1208 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_MATCHENTRYTOEXISTINGMESSAGE_1, "CPreallocatedFile::MatchEntryToExistingMessage()");
  1199 
  1209 
  1200 	aIndex = KErrNotFound;
  1210 	aIndex = KErrNotFound;
  1201 
  1211 
  1202 	//
  1212 	//
  1203 	// Search the reassembly store for a matching entry...
  1213 	// Search the reassembly store for a matching entry...
  1220 			aIndex = index;
  1230 			aIndex = index;
  1221 			break;
  1231 			break;
  1222 			}
  1232 			}
  1223 		}
  1233 		}
  1224 
  1234 
  1225 	LOGSMSPROT2("CPreallocatedFile::MatchEntryToExistingMessage(): aIndex=%d", aIndex);
  1235 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_MATCHENTRYTOEXISTINGMESSAGE_2, "CPreallocatedFile::MatchEntryToExistingMessage(): aIndex=%d", aIndex);
  1226 	}
  1236 	}
  1227 
  1237 
  1228 /*
  1238 /*
  1229 It updates the log server id of the message.
  1239 It updates the log server id of the message.
  1230 
  1240 
  1233 
  1243 
  1234 @internalComponent
  1244 @internalComponent
  1235 */
  1245 */
  1236 void CPreallocatedFile::UpdateLogServerIdL(TInt& aIndex, TLogId aLogServerId)
  1246 void CPreallocatedFile::UpdateLogServerIdL(TInt& aIndex, TLogId aLogServerId)
  1237 	{
  1247 	{
  1238 	LOGSMSPROT1("CPreallocatedFile::UpdateLogServerId");
  1248 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_UPDATELOGSERVERIDL_1, "CPreallocatedFile::UpdateLogServerId");
  1239 
  1249 
  1240 	TSmsPreAllocatedFileStoreReassemblyEntry entry;
  1250 	TSmsPreAllocatedFileStoreReassemblyEntry entry;
  1241 	entry = iEntryArray[aIndex];
  1251 	entry = iEntryArray[aIndex];
  1242 
  1252 
  1243 	if (entry.LogServerId() != aLogServerId)
  1253 	if (entry.LogServerId() != aLogServerId)
  1255 
  1265 
  1256 @internalComponent
  1266 @internalComponent
  1257 */
  1267 */
  1258 void CPreallocatedFile::SetPassedToClientL(TInt aIndex, TBool aBool)
  1268 void CPreallocatedFile::SetPassedToClientL(TInt aIndex, TBool aBool)
  1259 	{
  1269 	{
  1260 	LOGSMSPROT2("CPreallocatedFile::SetPassedToClientL(): aIndex=%d", aIndex);
  1270 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_SETPASSEDTOCLIENTL_1, "CPreallocatedFile::SetPassedToClientL(): aIndex=%d", aIndex);
  1261 
  1271 
  1262 	TSmsPreAllocatedFileStoreReassemblyEntry entry;
  1272 	TSmsPreAllocatedFileStoreReassemblyEntry entry;
  1263 	entry = iEntryArray[aIndex];
  1273 	entry = iEntryArray[aIndex];
  1264 
  1274 
  1265 	if (entry.PassedToClient() != aBool)
  1275 	if (entry.PassedToClient() != aBool)
  1276 
  1286 
  1277 @internalComponent
  1287 @internalComponent
  1278 */
  1288 */
  1279 void CPreallocatedFile::AddEntryL(TSmsPreAllocatedFileStoreReassemblyEntry& aEntry)
  1289 void CPreallocatedFile::AddEntryL(TSmsPreAllocatedFileStoreReassemblyEntry& aEntry)
  1280 	{
  1290 	{
  1281 	LOGSMSPROT1("CPreallocatedFile::AddEntryL");
  1291 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_ADDENTRYL_1, "CPreallocatedFile::AddEntryL");
  1282 	iEntryArray.AppendL(aEntry);
  1292 	iEntryArray.AppendL(aEntry);
  1283 	iEntryArray[iEntryArray.Count()-1].SetIsAdded(ETrue);
  1293 	iEntryArray[iEntryArray.Count()-1].SetIsAdded(ETrue);
  1284 	}
  1294 	}
  1285 
  1295 
  1286 /*
  1296 /*
  1291 
  1301 
  1292 @internalComponent
  1302 @internalComponent
  1293 */
  1303 */
  1294 void CPreallocatedFile::ChangeEntryL(TInt aIndex, const TSmsPreAllocatedFileStoreReassemblyEntry& aNewEntry)
  1304 void CPreallocatedFile::ChangeEntryL(TInt aIndex, const TSmsPreAllocatedFileStoreReassemblyEntry& aNewEntry)
  1295 	{
  1305 	{
  1296 	LOGSMSPROT2("CPreallocatedFile::ChangeEntryL(): aIndex=%d", aIndex);
  1306 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_CHANGEENTRYL_1, "CPreallocatedFile::ChangeEntryL(): aIndex=%d", aIndex);
  1297 	iEntryArray[aIndex].SetIsDeleted(ETrue);
  1307 	iEntryArray[aIndex].SetIsDeleted(ETrue);
  1298 	iEntryArray.InsertL(aIndex,aNewEntry);
  1308 	iEntryArray.InsertL(aIndex,aNewEntry);
  1299 	iEntryArray[aIndex].SetIsAdded(ETrue);
  1309 	iEntryArray[aIndex].SetIsAdded(ETrue);
  1300 	}
  1310 	}
  1301 
  1311 
  1306 
  1316 
  1307 @internalComponent
  1317 @internalComponent
  1308 */
  1318 */
  1309 void CPreallocatedFile::DeleteEntryL(TInt aIndex)
  1319 void CPreallocatedFile::DeleteEntryL(TInt aIndex)
  1310 	{
  1320 	{
  1311 	LOGSMSPROT2("CPreallocatedFile::DeleteEntryL(): aIndex=%d", aIndex);
  1321 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_DELETEENTRYL_1, "CPreallocatedFile::DeleteEntryL(): aIndex=%d", aIndex);
  1312 	if (iEntryArray[aIndex].PreAllocatedStorageId() != KErrNotFound)
  1322 	if (iEntryArray[aIndex].PreAllocatedStorageId() != KErrNotFound)
  1313 		{
  1323 		{
  1314 		ClearEntryL(iEntryArray[aIndex].PreAllocatedStorageId(), iEntryArray[aIndex].Count());
  1324 		ClearEntryL(iEntryArray[aIndex].PreAllocatedStorageId(), iEntryArray[aIndex].Count());
  1315 		}
  1325 		}
  1316 	iEntryArray[aIndex].SetIsDeleted(ETrue);
  1326 	iEntryArray[aIndex].SetIsDeleted(ETrue);
  1336 
  1346 
  1337 @internalComponent
  1347 @internalComponent
  1338 */
  1348 */
  1339 void CPreallocatedFile::ClearEntryL(TInt aStorageId, TInt aNumberOfPDUs)
  1349 void CPreallocatedFile::ClearEntryL(TInt aStorageId, TInt aNumberOfPDUs)
  1340 	{
  1350 	{
  1341 	LOGSMSPROT1("CPreallocatedFile::ClearEntryL");
  1351 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_CLEARENTRYL_1, "CPreallocatedFile::ClearEntryL");
  1342 
  1352 
  1343 	//Read storage id.
  1353 	//Read storage id.
  1344 	TInt storageId;
  1354 	TInt storageId;
  1345 	TPtr8 memPtr((TUint8*) &storageId, sizeof(storageId), sizeof(storageId));
  1355 	TPtr8 memPtr((TUint8*) &storageId, sizeof(storageId), sizeof(storageId));
  1346 	TInt beginOfStorageIdSection = KBeginOfMasterHeaderSection + KSizeOfNumberOfEntrySection + iSizeOfEntrySection;
  1356 	TInt beginOfStorageIdSection = KBeginOfMasterHeaderSection + KSizeOfNumberOfEntrySection + iSizeOfEntrySection;
  1484 
  1494 
  1485 @internalComponent
  1495 @internalComponent
  1486 */
  1496 */
  1487 void CPreallocatedFile::ExternalizeEntry(TInt aContainerId, const TGsmSmsSlotEntry& aSmsSlot, TInt aIndex, const TGsmSms& aGsmSms)
  1497 void CPreallocatedFile::ExternalizeEntry(TInt aContainerId, const TGsmSmsSlotEntry& aSmsSlot, TInt aIndex, const TGsmSms& aGsmSms)
  1488 	{
  1498 	{
  1489 	LOGSMSPROT3("CPreallocatedFile::ExternalizeEntry() 1: aContainerId=%d, aIndex=%d", aContainerId, aIndex);
  1499 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_EXTERNALIZEENTRY_1, "CPreallocatedFile::ExternalizeEntry() 1: aContainerId=%d, aIndex=%d", aContainerId, aIndex);
  1490 
  1500 
  1491 	// Container id must not be greater than max pdu segment.
  1501 	// Container id must not be greater than max pdu segment.
  1492 	TInt pos = iBeginOfDataSection + ((aContainerId - 1) * (KSizeOfGsmSmsSlotEntry + sizeof(TInt) + KSizeOfSmsGsmPDU));
  1502 	TInt pos = iBeginOfDataSection + ((aContainerId - 1) * (KSizeOfGsmSmsSlotEntry + sizeof(TInt) + KSizeOfSmsGsmPDU));
  1493 	// Store slot info
  1503 	// Store slot info
  1494 	TPtr8 memPtr((TUint8*) &aSmsSlot, sizeof(aSmsSlot), sizeof(aSmsSlot));
  1504 	TPtr8 memPtr((TUint8*) &aSmsSlot, sizeof(aSmsSlot), sizeof(aSmsSlot));
  1515 
  1525 
  1516 @internalComponent
  1526 @internalComponent
  1517 */
  1527 */
  1518 void CPreallocatedFile::ExternalizeEntry(TInt aContainerId, TInt aIndex, const TGsmSms& aGsmSms)
  1528 void CPreallocatedFile::ExternalizeEntry(TInt aContainerId, TInt aIndex, const TGsmSms& aGsmSms)
  1519 	{
  1529 	{
  1520 	LOGSMSPROT3("CPreallocatedFile::ExternalizeEntry() 2: aContainerId=%d, aIndex=%d", aContainerId, aIndex);
  1530 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_EXTERNALIZEENTRY1_1, "CPreallocatedFile::ExternalizeEntry() 2: aContainerId=%d, aIndex=%d", aContainerId, aIndex);
  1521 
  1531 
  1522 	// Container id must not be greater than max pdu segment.
  1532 	// Container id must not be greater than max pdu segment.
  1523 	TInt pos = iBeginOfDataSection + ((aContainerId - 1) * (KSizeOfGsmSmsSlotEntry + sizeof(TInt) + KSizeOfSmsGsmPDU));
  1533 	TInt pos = iBeginOfDataSection + ((aContainerId - 1) * (KSizeOfGsmSmsSlotEntry + sizeof(TInt) + KSizeOfSmsGsmPDU));
  1524 	// Store the PDU index value
  1534 	// Store the PDU index value
  1525 	TPtr8 memPtr((TUint8*) &aIndex, sizeof(aIndex), sizeof(aIndex));
  1535 	TPtr8 memPtr((TUint8*) &aIndex, sizeof(aIndex), sizeof(aIndex));
  1544 
  1554 
  1545 @internalComponent
  1555 @internalComponent
  1546 */
  1556 */
  1547 void CPreallocatedFile::InternalizeEntryL(const TInt aIndex, CSmsMessage& aSmsMessage, CArrayFix<TInt>& aIndexArray, CArrayFix<TGsmSms>& aSmsArray)
  1557 void CPreallocatedFile::InternalizeEntryL(const TInt aIndex, CSmsMessage& aSmsMessage, CArrayFix<TInt>& aIndexArray, CArrayFix<TGsmSms>& aSmsArray)
  1548 	{
  1558 	{
  1549 	LOGSMSPROT1("CPreallocatedFile::InternalizeEntryL");
  1559 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_INTERNALIZEENTRYL_1, "CPreallocatedFile::InternalizeEntryL");
  1550 	TSmsPreAllocatedFileStoreReassemblyEntry&  entry = iEntryArray[aIndex];
  1560 	TSmsPreAllocatedFileStoreReassemblyEntry&  entry = iEntryArray[aIndex];
  1551 	//Set other properties of CSmsMessage
  1561 	//Set other properties of CSmsMessage
  1552 	aSmsMessage.SetStorage(entry.Storage());
  1562 	aSmsMessage.SetStorage(entry.Storage());
  1553 	aSmsMessage.SetStatus((NMobileSmsStore::TMobileSmsStoreStatus)entry.Status());
  1563 	aSmsMessage.SetStatus((NMobileSmsStore::TMobileSmsStoreStatus)entry.Status());
  1554 	aSmsMessage.SetLogServerId(entry.LogServerId());
  1564 	aSmsMessage.SetLogServerId(entry.LogServerId());
  1556 	aSmsMessage.SetUTCOffset(entry.UTCOffset());
  1566 	aSmsMessage.SetUTCOffset(entry.UTCOffset());
  1557 	aSmsMessage.SetDecodedOnSIM(entry.DecodedOnSIM());
  1567 	aSmsMessage.SetDecodedOnSIM(entry.DecodedOnSIM());
  1558 	aSmsMessage.SetForwardToClient(entry.ForwardToClient());
  1568 	aSmsMessage.SetForwardToClient(entry.ForwardToClient());
  1559 	aSmsMessage.SetToFromAddressL(entry.Description2());
  1569 	aSmsMessage.SetToFromAddressL(entry.Description2());
  1560 
  1570 
  1561 	LOGSMSPROT2("CPreallocatedFile::InternalizeEntryL Start [sid=%d]", entry.PreAllocatedStorageId());
  1571 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_INTERNALIZEENTRYL_2, "CPreallocatedFile::InternalizeEntryL Start [sid=%d]", entry.PreAllocatedStorageId());
  1562 	if (entry.PreAllocatedStorageId()==KErrNotFound)
  1572 	if (entry.PreAllocatedStorageId()==KErrNotFound)
  1563 		{
  1573 		{
  1564 		return;
  1574 		return;
  1565 		}
  1575 		}
  1566 
  1576 
  1616 				break;
  1626 				break;
  1617 				}
  1627 				}
  1618 			}
  1628 			}
  1619 		}
  1629 		}
  1620 
  1630 
  1621 	LOGSMSPROT2("CPreallocatedFile::InternalizeEntryL End [noOfPDUsRead=%d]", noOfPDUsRead);
  1631 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_INTERNALIZEENTRYL_3, "CPreallocatedFile::InternalizeEntryL End [noOfPDUsRead=%d]", noOfPDUsRead);
  1622 	}
  1632 	}
  1623 
  1633 
  1624 /*
  1634 /*
  1625 It removes the PDUs from pre-allocated store file.
  1635 It removes the PDUs from pre-allocated store file.
  1626 This function is needed because after forwarding the incomplete message
  1636 This function is needed because after forwarding the incomplete message
  1634 
  1644 
  1635 @internalComponent
  1645 @internalComponent
  1636 */
  1646 */
  1637 void CPreallocatedFile::RemovePDUsL(TInt aIndex, TInt aStartPos, TInt aEndPos)
  1647 void CPreallocatedFile::RemovePDUsL(TInt aIndex, TInt aStartPos, TInt aEndPos)
  1638 	{
  1648 	{
  1639 	LOGSMSPROT1("CPreallocatedFile::RemovePDUsL");
  1649 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_REMOVEPDUSL_1, "CPreallocatedFile::RemovePDUsL");
  1640 
  1650 
  1641 	if ((aStartPos < 1) || (aEndPos > 256) || (aStartPos > aEndPos))
  1651 	if ((aStartPos < 1) || (aEndPos > 256) || (aStartPos > aEndPos))
  1642 		{
  1652 		{
  1643 		User::Leave(KErrArgument);
  1653 		User::Leave(KErrArgument);
  1644 		}
  1654 		}
  1645 
  1655 
  1646 	LOGSMSPROT2("CPreallocatedFile::RemovePDUsL Start [sid=%d]", iEntryArray[aIndex].PreAllocatedStorageId());
  1656 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_REMOVEPDUSL_2, "CPreallocatedFile::RemovePDUsL Start [sid=%d]", iEntryArray[aIndex].PreAllocatedStorageId());
  1647 	if (iEntryArray[aIndex].PreAllocatedStorageId()==KErrNotFound)
  1657 	if (iEntryArray[aIndex].PreAllocatedStorageId()==KErrNotFound)
  1648 		{
  1658 		{
  1649 		return;
  1659 		return;
  1650 		}
  1660 		}
  1651 
  1661 
  1879  *  invalid.
  1889  *  invalid.
  1880  *  @capability None
  1890  *  @capability None
  1881  */
  1891  */
  1882 void CPreallocatedFile::BeginTransactionL()
  1892 void CPreallocatedFile::BeginTransactionL()
  1883 	{
  1893 	{
  1884 	LOGSMSPROT3("CPreallocatedFile::BeginTransactionL [this=0x%08X iInTransaction=%d]", this, iInTransaction);
  1894 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_BEGINTRANSACTIONL_1, "CPreallocatedFile::BeginTransactionL [this=0x%08X iInTransaction=%d]", (TUint)this, iInTransaction);
  1885 
  1895 
  1886 	if (iInTransaction)
  1896 	if (iInTransaction)
  1887 		{
  1897 		{
  1888 	    LOGGSMU1("WARNING CPreallocatedFile::BeginTransactionL leaving with KErrAccessDenied");
  1898 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_BEGINTRANSACTIONL_2, "WARNING CPreallocatedFile::BeginTransactionL leaving with KErrAccessDenied");
  1889 		User::Leave(KErrAccessDenied);
  1899 		User::Leave(KErrAccessDenied);
  1890 		}
  1900 		}
  1891 
  1901 
  1892 	iInTransaction = ETrue;
  1902 	iInTransaction = ETrue;
  1893 	}
  1903 	}
  1895 /**
  1905 /**
  1896  *  It commits the transaction.
  1906  *  It commits the transaction.
  1897  */
  1907  */
  1898 void CPreallocatedFile::CommitTransactionL()
  1908 void CPreallocatedFile::CommitTransactionL()
  1899 	{
  1909 	{
  1900 	LOGSMSPROT3("CPreallocatedFile::CommitTransactionL(): this=0x%08X iInTransaction=%d",
  1910 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_COMMITTRANSACTIONL_1, "CPreallocatedFile::CommitTransactionL(): this=0x%08X iInTransaction=%d",(TUint)this, iInTransaction);
  1901 				this, iInTransaction);
       
  1902 
  1911 
  1903 	ExternalizeEntryArray();
  1912 	ExternalizeEntryArray();
  1904 	//Commit
  1913 	//Commit
  1905 	PutChecksumValueL();
  1914 	PutChecksumValueL();
  1906 	iInTransaction = EFalse;
  1915 	iInTransaction = EFalse;
  1911 /*
  1920 /*
  1912 It reverts the transaction.
  1921 It reverts the transaction.
  1913 */
  1922 */
  1914 void CPreallocatedFile::Revert()
  1923 void CPreallocatedFile::Revert()
  1915 	{
  1924 	{
  1916 	LOGSMSPROT3("CPreallocatedFile::Revert(): this=0x%08X, iInTransaction=%d",
  1925 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_REVERT_1, "CPreallocatedFile::Revert(): this=0x%08X, iInTransaction=%d",(TUint)this, iInTransaction);
  1917     		 this, iInTransaction);
       
  1918 
  1926 
  1919 	ReinstateEntries();
  1927 	ReinstateEntries();
  1920 	ExternalizeEntryArray();
  1928 	ExternalizeEntryArray();
  1921 	iInTransaction = EFalse;
  1929 	iInTransaction = EFalse;
  1922 	ReinstateDeletedEntries();
  1930 	ReinstateDeletedEntries();
  1926  *  It removes the deleted entries from entry arry.
  1934  *  It removes the deleted entries from entry arry.
  1927  *	This function is called after commit.
  1935  *	This function is called after commit.
  1928  */
  1936  */
  1929 void CPreallocatedFile::RemoveDeletedEntries()
  1937 void CPreallocatedFile::RemoveDeletedEntries()
  1930 	{
  1938 	{
  1931 	LOGSMSPROT1("CPreallocatedFile::RemoveDeletedEntries()");
  1939 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_REMOVEDELETEDENTRIES_1, "CPreallocatedFile::RemoveDeletedEntries()");
  1932 
  1940 
  1933 	TInt count=iEntryArray.Count();
  1941 	TInt count=iEntryArray.Count();
  1934 	while (count--)
  1942 	while (count--)
  1935 		{
  1943 		{
  1936 		TSmsPreAllocatedFileStoreReassemblyEntry& entry = iEntryArray[count];
  1944 		TSmsPreAllocatedFileStoreReassemblyEntry& entry = iEntryArray[count];
  1950  *  It reinstate the deleted/added entries from entry arry.
  1958  *  It reinstate the deleted/added entries from entry arry.
  1951  *	This function is called after revert operation.
  1959  *	This function is called after revert operation.
  1952  */
  1960  */
  1953 void CPreallocatedFile::ReinstateDeletedEntries()
  1961 void CPreallocatedFile::ReinstateDeletedEntries()
  1954 	{
  1962 	{
  1955 	LOGSMSPROT1("CPreallocatedFile::ReinstateDeletedEntries()");
  1963 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_REINSTATEDELETEDENTRIES_1, "CPreallocatedFile::ReinstateDeletedEntries()");
  1956 
  1964 
  1957 	TInt count=iEntryArray.Count();
  1965 	TInt count=iEntryArray.Count();
  1958 	while (count--)
  1966 	while (count--)
  1959 		{
  1967 		{
  1960 		TSmsPreAllocatedFileStoreReassemblyEntry& entry = iEntryArray[count];
  1968 		TSmsPreAllocatedFileStoreReassemblyEntry& entry = iEntryArray[count];
  1976  *	Unlike permanent store file which supports revert. pre-allocated
  1984  *	Unlike permanent store file which supports revert. pre-allocated
  1977  *	file (raw data file) supports the revert mecahnism using this function.
  1985  *	file (raw data file) supports the revert mecahnism using this function.
  1978  */
  1986  */
  1979 void CPreallocatedFile::ReinstateEntries()
  1987 void CPreallocatedFile::ReinstateEntries()
  1980 	{
  1988 	{
  1981 	LOGSMSPROT1("CPreallocatedFile::ReinstateEntries()");
  1989 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_REINSTATEENTRIES_1, "CPreallocatedFile::ReinstateEntries()");
  1982 
  1990 
  1983 	TInt containerId;
  1991 	TInt containerId;
  1984 	TInt storageId;
  1992 	TInt storageId;
  1985 	TPtr8 memPtr((TUint8*) &storageId, sizeof(storageId), sizeof(storageId));
  1993 	TPtr8 memPtr((TUint8*) &storageId, sizeof(storageId), sizeof(storageId));
  1986 
  1994 
  2012 /*
  2020 /*
  2013 It returns the index of oldest message in pre-allocated file.
  2021 It returns the index of oldest message in pre-allocated file.
  2014 */
  2022 */
  2015 TInt CPreallocatedFile::GetOldestMessageEntryIndex()
  2023 TInt CPreallocatedFile::GetOldestMessageEntryIndex()
  2016 	{
  2024 	{
  2017 	LOGSMSPROT1("CPreallocatedFile::GetOldestMessageEntryIndex()");
  2025 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPREALLOCATEDFILE_GETOLDESTMESSAGEENTRYINDEX_1, "CPreallocatedFile::GetOldestMessageEntryIndex()");
  2018 
  2026 
  2019 	TInt index = KErrNotFound;
  2027 	TInt index = KErrNotFound;
  2020 	TTime time;
  2028 	TTime time;
  2021 	time.UniversalTime();
  2029 	time.UniversalTime();
  2022 
  2030 
  2042 
  2050 
  2043 @internalComponent
  2051 @internalComponent
  2044 */
  2052 */
  2045 CGuardTimer* CGuardTimer::NewL(CClass0SmsReassemblyStore& aClass0ReassemblyStore, TInt aGuardTimeout)
  2053 CGuardTimer* CGuardTimer::NewL(CClass0SmsReassemblyStore& aClass0ReassemblyStore, TInt aGuardTimeout)
  2046 	{
  2054 	{
  2047 	LOGSMSPROT1("CGuardTimer::NewL()");
  2055 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CGUARDTIMER_NEWL_1, "CGuardTimer::NewL()");
  2048 
  2056 
  2049 	CGuardTimer* timer = new(ELeave) CGuardTimer(aClass0ReassemblyStore, aGuardTimeout);
  2057 	CGuardTimer* timer = new(ELeave) CGuardTimer(aClass0ReassemblyStore, aGuardTimeout);
  2050 	CleanupStack::PushL(timer);
  2058 	CleanupStack::PushL(timer);
  2051 	timer->ConstructL();
  2059 	timer->ConstructL();
  2052 	CleanupStack::Pop();
  2060 	CleanupStack::Pop();
  2075 /**
  2083 /**
  2076  *  Enable the Gurad Timer
  2084  *  Enable the Gurad Timer
  2077  */
  2085  */
  2078 void CGuardTimer::EnableGuardTimer()
  2086 void CGuardTimer::EnableGuardTimer()
  2079 	{
  2087 	{
  2080 	LOGSMSPROT1("CGuardTimer::EnableGuardTimer()");
  2088 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CGUARDTIMER_ENABLEGUARDTIMER_1, "CGuardTimer::EnableGuardTimer()");
  2081 	if (!IsActive())
  2089 	if (!IsActive())
  2082 		{
  2090 		{
  2083 		TTime nextTimeOut;
  2091 		TTime nextTimeOut;
  2084 		iClass0ReassemblyStore.GetNextGuardTimeout(nextTimeOut);
  2092 		iClass0ReassemblyStore.GetNextGuardTimeout(nextTimeOut);
  2085 		At(nextTimeOut);
  2093 		At(nextTimeOut);
  2097 /**
  2105 /**
  2098  *  Timer completed
  2106  *  Timer completed
  2099  */
  2107  */
  2100 void CGuardTimer::RunL()
  2108 void CGuardTimer::RunL()
  2101 	{
  2109 	{
  2102 	LOGSMSPROT2("CGuardTimer::RunL [iStatus=%d]", iStatus.Int());
  2110 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CGUARDTIMER_RUNL_1, "CGuardTimer::RunL [iStatus=%d]", iStatus.Int());
  2103 	iClass0ReassemblyStore.ProcessTimeoutMessageL();
  2111 	iClass0ReassemblyStore.ProcessTimeoutMessageL();
  2104 	EnableGuardTimer();
  2112 	EnableGuardTimer();
  2105 	} // CGuardTimer::RunL
  2113 	} // CGuardTimer::RunL
  2106 
  2114 
  2107 /**
  2115 /**
  2118 
  2126 
  2119 @internalComponent
  2127 @internalComponent
  2120 */
  2128 */
  2121 CClass0SmsReassemblyStore* CClass0SmsReassemblyStore::NewL(RFs& aFs, MSmsComm& aSmsComm)
  2129 CClass0SmsReassemblyStore* CClass0SmsReassemblyStore::NewL(RFs& aFs, MSmsComm& aSmsComm)
  2122 	{
  2130 	{
  2123 	LOGSMSPROT1("CClass0SmsReassemblyStore::NewL()");
  2131 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_NEWL_1, "CClass0SmsReassemblyStore::NewL()");
  2124 
  2132 
  2125 	CClass0SmsReassemblyStore*  self = new (ELeave) CClass0SmsReassemblyStore(aFs, aSmsComm);
  2133 	CClass0SmsReassemblyStore*  self = new (ELeave) CClass0SmsReassemblyStore(aFs, aSmsComm);
  2126 	CleanupStack::PushL(self);
  2134 	CleanupStack::PushL(self);
  2127 	self->ConstructL();
  2135 	self->ConstructL();
  2128 	CleanupStack::Pop(self);
  2136 	CleanupStack::Pop(self);
  2186 
  2194 
  2187 @internalComponent
  2195 @internalComponent
  2188 */
  2196 */
  2189 void CClass0SmsReassemblyStore::ReadConfigurableClass0SmsSettingsL(TInt& aMaxClass0Msg, TInt& aMaxPDUSeg, TInt& aGuardTimeOut)
  2197 void CClass0SmsReassemblyStore::ReadConfigurableClass0SmsSettingsL(TInt& aMaxClass0Msg, TInt& aMaxPDUSeg, TInt& aGuardTimeOut)
  2190 	{
  2198 	{
  2191 	LOGSMSPROT1("CClass0SmsReassemblyStore::ReadConfigurableClass0SmsSettingsL()");
  2199 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_READCONFIGURABLECLASS0SMSSETTINGSL_1, "CClass0SmsReassemblyStore::ReadConfigurableClass0SmsSettingsL()");
  2192 
  2200 
  2193 	aMaxClass0Msg = KMaxNumberOfClass0MessagesInReassemblyStore;
  2201 	aMaxClass0Msg = KMaxNumberOfClass0MessagesInReassemblyStore;
  2194 	aMaxPDUSeg    = KNumberOfPDUSegmentsStoredInOODCondition;
  2202 	aMaxPDUSeg    = KNumberOfPDUSegmentsStoredInOODCondition;
  2195 	aGuardTimeOut = KGuardTimeOut;
  2203 	aGuardTimeOut = KGuardTimeOut;
  2196 
  2204 
  2197 	CESockIniData*  ini = NULL;
  2205 	CESockIniData*  ini = NULL;
  2198 	TRAPD(ret, ini=CESockIniData::NewL(_L("smswap.sms.esk")));
  2206 	TRAPD(ret, ini=CESockIniData::NewL(_L("smswap.sms.esk")));
  2199 	if(ret!=KErrNone)
  2207 	if(ret!=KErrNone)
  2200 		{
  2208 		{
  2201 		LOGSMSPROT2("CESockIniData::NewL() returned=%d", ret);
  2209 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_READCONFIGURABLECLASS0SMSSETTINGSL_2, "CESockIniData::NewL() returned=%d", ret);
  2202 		}
  2210 		}
  2203 	else
  2211 	else
  2204 		{
  2212 		{
  2205 		CleanupStack::PushL(ini);
  2213 		CleanupStack::PushL(ini);
  2206 
  2214 
  2207 		TInt var(0);
  2215 		TInt var(0);
  2208 		if(ini->FindVar(_L("ReassemblyStore"),_L("MaxClass0Messages"),var))
  2216 		if(ini->FindVar(_L("ReassemblyStore"),_L("MaxClass0Messages"),var))
  2209 			{
  2217 			{
  2210 			if (var > 0)
  2218 			if (var > 0)
  2211 				{
  2219 				{
  2212 				LOGSMSPROT2("MaxClass0Messages [%d]", var);
  2220 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_READCONFIGURABLECLASS0SMSSETTINGSL_3, "MaxClass0Messages [%d]", var);
  2213 				aMaxClass0Msg = var;
  2221 				aMaxClass0Msg = var;
  2214 				}
  2222 				}
  2215 			}
  2223 			}
  2216 
  2224 
  2217 		if(ini->FindVar(_L("ReassemblyStore"),_L("NumberOfPDUSegements"),var))
  2225 		if(ini->FindVar(_L("ReassemblyStore"),_L("NumberOfPDUSegements"),var))
  2218 			{
  2226 			{
  2219 			if (var > 0)
  2227 			if (var > 0)
  2220 				{
  2228 				{
  2221 				LOGSMSPROT2("MaxClass0Messages [%d]", var);
  2229 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_READCONFIGURABLECLASS0SMSSETTINGSL_4, "MaxClass0Messages [%d]", var);
  2222 				aMaxPDUSeg = var;
  2230 				aMaxPDUSeg = var;
  2223 				}
  2231 				}
  2224 			}
  2232 			}
  2225 
  2233 
  2226 		if(ini->FindVar(_L("ReassemblyStore"),_L("GuardTimeOut"),var))
  2234 		if(ini->FindVar(_L("ReassemblyStore"),_L("GuardTimeOut"),var))
  2227 			{
  2235 			{
  2228 			if (var > 0)
  2236 			if (var > 0)
  2229 				{
  2237 				{
  2230 				LOGSMSPROT2("MaxClass0Messages [%d]", var);
  2238 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_READCONFIGURABLECLASS0SMSSETTINGSL_5, "MaxClass0Messages [%d]", var);
  2231 				aGuardTimeOut = var;
  2239 				aGuardTimeOut = var;
  2232 				}
  2240 				}
  2233 			}
  2241 			}
  2234 
  2242 
  2235 		CleanupStack::PopAndDestroy(ini);
  2243 		CleanupStack::PopAndDestroy(ini);
  2236 		}
  2244 		}
  2237 
  2245 
  2238 	LOGSMSPROT4("CClass0SmsReassemblyStore::ReadConfigurableClass0SmsSettingsL(): aMaxClass0Msg=%d, aMaxPDUSeg=%d, aGuardTimeOut=%d",
  2246 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_READCONFIGURABLECLASS0SMSSETTINGSL_6, "CClass0SmsReassemblyStore::ReadConfigurableClass0SmsSettingsL(): aMaxClass0Msg=%d, aMaxPDUSeg=%d, aGuardTimeOut=%d",aMaxClass0Msg, aMaxPDUSeg, aGuardTimeOut);
  2239 			    aMaxClass0Msg, aMaxPDUSeg, aGuardTimeOut);
       
  2240 	}
  2247 	}
  2241 
  2248 
  2242 /**
  2249 /**
  2243 It opens the class 0 re-assembly store.
  2250 It opens the class 0 re-assembly store.
  2244 Then it populates the entry information (all the messages stored in re-assembly store).
  2251 Then it populates the entry information (all the messages stored in re-assembly store).
  2245 
  2252 
  2246 @internalComponent
  2253 @internalComponent
  2247 */
  2254 */
  2248 void CClass0SmsReassemblyStore::OpenStoreL()
  2255 void CClass0SmsReassemblyStore::OpenStoreL()
  2249 	{
  2256 	{
  2250 	LOGSMSPROT1("CClass0SmsReassemblyStore::OpenStoreL()");
  2257 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_OPENSTOREL_1, "CClass0SmsReassemblyStore::OpenStoreL()");
  2251 	TFileName pathName;
  2258 	TFileName pathName;
  2252 	CReassemblyStoreUtility::PrivatePath(iFs, pathName);
  2259 	CReassemblyStoreUtility::PrivatePath(iFs, pathName);
  2253 	//Create the directory if it is not created.
  2260 	//Create the directory if it is not created.
  2254 	iFs.MkDirAll(pathName);
  2261 	iFs.MkDirAll(pathName);
  2255 	// If any one file becomes corrupt or does not exist then we have to create both files.
  2262 	// If any one file becomes corrupt or does not exist then we have to create both files.
  2272 
  2279 
  2273 @internalComponent
  2280 @internalComponent
  2274 */
  2281 */
  2275 void CClass0SmsReassemblyStore::Close()
  2282 void CClass0SmsReassemblyStore::Close()
  2276 	{
  2283 	{
  2277 	LOGSMSPROT1("CClass0SmsReassemblyStore::CloseStore()");
  2284 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_CLOSE_1, "CClass0SmsReassemblyStore::CloseStore()");
  2278 	iGuardTimer->DisableGuardTimer();
  2285 	iGuardTimer->DisableGuardTimer();
  2279 	iEntryArray.Reset();
  2286 	iEntryArray.Reset();
  2280 	iPreallocatedFile->Close();
  2287 	iPreallocatedFile->Close();
  2281 	iPermanentFileStore->Close();
  2288 	iPermanentFileStore->Close();
  2282 	}
  2289 	}
  2288 
  2295 
  2289 @internalComponent
  2296 @internalComponent
  2290 */
  2297 */
  2291 void CClass0SmsReassemblyStore::PopulateEntryArrayL(CArrayFix<TReassemblyEntry>& aEntryArray)
  2298 void CClass0SmsReassemblyStore::PopulateEntryArrayL(CArrayFix<TReassemblyEntry>& aEntryArray)
  2292 	{
  2299 	{
  2293 	LOGSMSPROT1("CClass0SmsReassemblyStore::PopulateEntryArrayL()");
  2300 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_POPULATEENTRYARRAYL_1, "CClass0SmsReassemblyStore::PopulateEntryArrayL()");
  2294 	aEntryArray.Reset();
  2301 	aEntryArray.Reset();
  2295 	//Populate Entries from Pre-allocated file.
  2302 	//Populate Entries from Pre-allocated file.
  2296 	for (TInt count = 0; count < iPreallocatedFile->Entries().Count(); count++)
  2303 	for (TInt count = 0; count < iPreallocatedFile->Entries().Count(); count++)
  2297 		{
  2304 		{
  2298 		TReassemblyEntry entry;
  2305 		TReassemblyEntry entry;
  2353 				}
  2360 				}
  2354 			}
  2361 			}
  2355 		}
  2362 		}
  2356 	else if (ret == KErrDiskFull)
  2363 	else if (ret == KErrDiskFull)
  2357 		{
  2364 		{
  2358 		LOGSMSPROT1("CleanReassemblyEntries() returns KErrDiskFull");
  2365 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_POPULATEENTRYARRAYL_2, "CleanReassemblyEntries() returns KErrDiskFull");
  2359 		/*
  2366 		/*
  2360 		In this case permanent store file contains incorrect information.
  2367 		In this case permanent store file contains incorrect information.
  2361 		For example forwarded message might be still stored in this store.
  2368 		For example forwarded message might be still stored in this store.
  2362 		Because it has not been deleted due to out-of-disk condition.
  2369 		Because it has not been deleted due to out-of-disk condition.
  2363 		So be careful at the time of updating the count information
  2370 		So be careful at the time of updating the count information
  2421 If disk space is full, then class 0 re-assembly store stores the incoming message in
  2428 If disk space is full, then class 0 re-assembly store stores the incoming message in
  2422 pre-allocated file. Otherwise it stores the message in permanent store file.
  2429 pre-allocated file. Otherwise it stores the message in permanent store file.
  2423 */
  2430 */
  2424 void CClass0SmsReassemblyStore::SetDiskSpaceState(TSmsDiskSpaceMonitorStatus aDiskSpaceStatus)
  2431 void CClass0SmsReassemblyStore::SetDiskSpaceState(TSmsDiskSpaceMonitorStatus aDiskSpaceStatus)
  2425 	{
  2432 	{
  2426 	LOGSMSPROT1("CClass0SmsReassemblyStore::SetDiskSpaceState()");
  2433 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_SETDISKSPACESTATE_1, "CClass0SmsReassemblyStore::SetDiskSpaceState()");
  2427 	iDiskSpaceStatus = aDiskSpaceStatus;
  2434 	iDiskSpaceStatus = aDiskSpaceStatus;
  2428 	}
  2435 	}
  2429 
  2436 
  2430 /*
  2437 /*
  2431 It adds the new message in class 0 reassembly store.
  2438 It adds the new message in class 0 reassembly store.
  2439 
  2446 
  2440 @internalComponent
  2447 @internalComponent
  2441 */
  2448 */
  2442 void CClass0SmsReassemblyStore::AddNewMessageL(CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms)
  2449 void CClass0SmsReassemblyStore::AddNewMessageL(CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms)
  2443 	{
  2450 	{
  2444 	LOGSMSPROT1("CClass0SmsReassemblyStore::AddNewMessageL");
  2451 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_ADDNEWMESSAGEL_1, "CClass0SmsReassemblyStore::AddNewMessageL");
  2445 
  2452 
  2446 	// Add entry in permanent store file
  2453 	// Add entry in permanent store file
  2447 	TInt index;
  2454 	TInt index;
  2448 	TInt ret = KErrNone;
  2455 	TInt ret = KErrNone;
  2449 
  2456 
  2497 
  2504 
  2498 @internalComponent
  2505 @internalComponent
  2499 */
  2506 */
  2500 void CClass0SmsReassemblyStore::UpdateExistingMessageL(CSmsMessage& aSmsMessage, const TGsmSms& aGsmSms, TBool& aDuplicateMsgRef, TBool& aDuplicateSlot)
  2507 void CClass0SmsReassemblyStore::UpdateExistingMessageL(CSmsMessage& aSmsMessage, const TGsmSms& aGsmSms, TBool& aDuplicateMsgRef, TBool& aDuplicateSlot)
  2501 	{
  2508 	{
  2502 	LOGSMSPROT1("CClass0SmsReassemblyStore::UpdateExistingMessageL()");
  2509 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_UPDATEEXISTINGMESSAGEL_1, "CClass0SmsReassemblyStore::UpdateExistingMessageL()");
  2503 
  2510 
  2504 	aDuplicateMsgRef = EFalse;
  2511 	aDuplicateMsgRef = EFalse;
  2505 	aDuplicateSlot   = EFalse;
  2512 	aDuplicateSlot   = EFalse;
  2506 
  2513 
  2507 	CSmsBuffer*  buffer = CSmsBuffer::NewL();
  2514 	CSmsBuffer*  buffer = CSmsBuffer::NewL();
  2557 			{
  2564 			{
  2558 			const TGsmSmsSlotEntry&  slot = smsMessage->iSlotArray[slotNum];
  2565 			const TGsmSmsSlotEntry&  slot = smsMessage->iSlotArray[slotNum];
  2559 
  2566 
  2560 			if (slot.iIndex == newSlot.iIndex  && slot.iStore == newSlot.iStore)
  2567 			if (slot.iIndex == newSlot.iIndex  && slot.iStore == newSlot.iStore)
  2561 				{
  2568 				{
  2562 				LOGSMSPROT1("CSmsReassemblyStore::UpdateExistingMessageL(): Duplicate enumerated PDU.");
  2569 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_UPDATEEXISTINGMESSAGEL_2, "CSmsReassemblyStore::UpdateExistingMessageL(): Duplicate enumerated PDU.");
  2563 
  2570 
  2564 				// It is a duplicate that was already stored on the SIM...
  2571 				// It is a duplicate that was already stored on the SIM...
  2565 				aDuplicateSlot = ETrue;
  2572 				aDuplicateSlot = ETrue;
  2566 				break;
  2573 				break;
  2567 				}
  2574 				}
  2572 
  2579 
  2573 	for (TInt index = 0;  index < indexArrayCount;  index++ )
  2580 	for (TInt index = 0;  index < indexArrayCount;  index++ )
  2574 		{
  2581 		{
  2575 		if (indexArray->At(index) == concatPDUIndex)
  2582 		if (indexArray->At(index) == concatPDUIndex)
  2576 			{
  2583 			{
  2577 			LOGSMSPROT1("CSmsReassemblyStore::UpdateExistingMessageL(): Duplicate concatenated PDU.");
  2584 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_UPDATEEXISTINGMESSAGEL_3, "CSmsReassemblyStore::UpdateExistingMessageL(): Duplicate concatenated PDU.");
  2578 
  2585 
  2579 			// The PDU is already stored in the reassembly store.
  2586 			// The PDU is already stored in the reassembly store.
  2580 			aDuplicateMsgRef = ETrue;
  2587 			aDuplicateMsgRef = ETrue;
  2581 			break;
  2588 			break;
  2582 			}
  2589 			}
  3059 
  3066 
  3060 @internalComponent
  3067 @internalComponent
  3061 */
  3068 */
  3062 void CClass0SmsReassemblyStore::ProcessTimeoutMessageL()
  3069 void CClass0SmsReassemblyStore::ProcessTimeoutMessageL()
  3063 	{
  3070 	{
  3064 	LOGSMSPROT1("CClass0SmsReassemblyStore::ProcessTimeoutMessageL()");
  3071 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_PROCESSTIMEOUTMESSAGEL_1, "CClass0SmsReassemblyStore::ProcessTimeoutMessageL()");
  3065 	TBool passedToClient=ETrue;
  3072 	TBool passedToClient=ETrue;
  3066 	TInt count=iEntryArray.Count();
  3073 	TInt count=iEntryArray.Count();
  3067 
  3074 
  3068 	CSmsBuffer* buffer = CSmsBuffer::NewL();
  3075 	CSmsBuffer* buffer = CSmsBuffer::NewL();
  3069 	CSmsMessage* smsMessage = CSmsMessage::NewL(iFs, CSmsPDU::ESmsDeliver, buffer );
  3076 	CSmsMessage* smsMessage = CSmsMessage::NewL(iFs, CSmsPDU::ESmsDeliver, buffer );
  3183 
  3190 
  3184 @internalComponent
  3191 @internalComponent
  3185 */
  3192 */
  3186 void CClass0SmsReassemblyStore::SetIncompleteMessageForwardedToClientL(const CSmsMessage& aSmsMessage)
  3193 void CClass0SmsReassemblyStore::SetIncompleteMessageForwardedToClientL(const CSmsMessage& aSmsMessage)
  3187 	{
  3194 	{
  3188 	LOGSMSPROT1("CClass0SmsReassemblyStore::SetIncompleteMessageForwardedToClientL()");
  3195 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_SETINCOMPLETEMESSAGEFORWARDEDTOCLIENTL_1, "CClass0SmsReassemblyStore::SetIncompleteMessageForwardedToClientL()");
  3189 	TInt index = KErrNotFound;
  3196 	TInt index = KErrNotFound;
  3190 
  3197 
  3191 	if (aSmsMessage.IsComplete())
  3198 	if (aSmsMessage.IsComplete())
  3192 		{
  3199 		{
  3193 		LOGSMSPROT1("This function must be called when message is incomplete");
  3200 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_SETINCOMPLETEMESSAGEFORWARDEDTOCLIENTL_2, "This function must be called when message is incomplete");
  3194 		User::Leave(KErrArgument);
  3201 		User::Leave(KErrArgument);
  3195 		}
  3202 		}
  3196 
  3203 
  3197 	if (FindMessageL(aSmsMessage, EFalse, index))
  3204 	if (FindMessageL(aSmsMessage, EFalse, index))
  3198 		{
  3205 		{
  3244 
  3251 
  3245 @internalComponent
  3252 @internalComponent
  3246 */
  3253 */
  3247 TInt CClass0SmsReassemblyStore::CleanReassemblyEntries()
  3254 TInt CClass0SmsReassemblyStore::CleanReassemblyEntries()
  3248 	{
  3255 	{
  3249 	LOGSMSPROT1("CleanReassemblyEntries");
  3256 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_CLEANREASSEMBLYENTRIES_1, "CleanReassemblyEntries");
  3250 	const CArrayFix<TSmsPreAllocatedFileStoreReassemblyEntry>& preAllocatedFileEntryArray = iPreallocatedFile->Entries();
  3257 	const CArrayFix<TSmsPreAllocatedFileStoreReassemblyEntry>& preAllocatedFileEntryArray = iPreallocatedFile->Entries();
  3251 	TInt ret=KErrNone;
  3258 	TInt ret=KErrNone;
  3252 	TRAP(ret,	BeginTransactionLC();
  3259 	TRAP(ret,	BeginTransactionLC();
  3253 				iPermanentFileStore->CleanupEntriesL(preAllocatedFileEntryArray);
  3260 				iPermanentFileStore->CleanupEntriesL(preAllocatedFileEntryArray);
  3254 				CommitTransactionL(););
  3261 				CommitTransactionL(););
  3255 
  3262 
  3256 	if (ret == KErrDiskFull)
  3263 	if (ret == KErrDiskFull)
  3257 		{
  3264 		{
  3258 		LOGSMSPROT1("CleanupEntriesL returns KErrDiskFull");
  3265 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_CLEANREASSEMBLYENTRIES_2, "CleanupEntriesL returns KErrDiskFull");
  3259 		/*
  3266 		/*
  3260 		Get access to reserve memory, call again to clean the entries with compact.
  3267 		Get access to reserve memory, call again to clean the entries with compact.
  3261 		Compact needs to be called at this instance because permanent store
  3268 		Compact needs to be called at this instance because permanent store
  3262 		will use reserve disk space to delete, but after deletion reserve
  3269 		will use reserve disk space to delete, but after deletion reserve
  3263 		disk space will be freed. So compact will make sure that reserve disk
  3270 		disk space will be freed. So compact will make sure that reserve disk
  3265 		*/
  3272 		*/
  3266 		iFs.GetReserveAccess(KStoreDrive);
  3273 		iFs.GetReserveAccess(KStoreDrive);
  3267 		TRAP(ret,	BeginTransactionLC();
  3274 		TRAP(ret,	BeginTransactionLC();
  3268 					iPermanentFileStore->CleanupEntriesWithCompactL(preAllocatedFileEntryArray);
  3275 					iPermanentFileStore->CleanupEntriesWithCompactL(preAllocatedFileEntryArray);
  3269 					CommitTransactionL(););
  3276 					CommitTransactionL(););
  3270 		LOGSMSPROT2("CleanupEntriesWithCompactL returns %d", ret);
  3277 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_CLEANREASSEMBLYENTRIES_3, "CleanupEntriesWithCompactL returns %d", ret);
  3271 		iFs.ReleaseReserveAccess(KStoreDrive);
  3278 		iFs.ReleaseReserveAccess(KStoreDrive);
  3272 		}
  3279 		}
  3273 	return ret;
  3280 	return ret;
  3274 	}
  3281 	}
  3275 
  3282 
  3285 
  3292 
  3286 @internalComponent
  3293 @internalComponent
  3287 */
  3294 */
  3288 void CClass0SmsReassemblyStore::GetSmsEntriesL(const TReassemblyEntry& aEntry, CSmsMessage& aSmsMessage, CArrayFix<TInt>& aIndexArray, CArrayFix<TGsmSms>& aSmsArray)
  3295 void CClass0SmsReassemblyStore::GetSmsEntriesL(const TReassemblyEntry& aEntry, CSmsMessage& aSmsMessage, CArrayFix<TInt>& aIndexArray, CArrayFix<TGsmSms>& aSmsArray)
  3289 	{
  3296 	{
  3290 	LOGSMSPROT1("CClass0SmsReassemblyStore::GetSmsEntriesL()");
  3297 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_GETSMSENTRIESL_1, "CClass0SmsReassemblyStore::GetSmsEntriesL()");
  3291 	TInt permanentStoreIndex=KErrNotFound;
  3298 	TInt permanentStoreIndex=KErrNotFound;
  3292 	iPermanentFileStore->MatchEntryToExistingMessage(aEntry, permanentStoreIndex);
  3299 	iPermanentFileStore->MatchEntryToExistingMessage(aEntry, permanentStoreIndex);
  3293 	if (permanentStoreIndex!=KErrNotFound)
  3300 	if (permanentStoreIndex!=KErrNotFound)
  3294 		{
  3301 		{
  3295 		iPermanentFileStore->InternalizeEntryL(permanentStoreIndex, aSmsMessage, aIndexArray, aSmsArray);
  3302 		iPermanentFileStore->InternalizeEntryL(permanentStoreIndex, aSmsMessage, aIndexArray, aSmsArray);
  3296 		}
  3303 		}
  3297 	else
  3304 	else
  3298 		{
  3305 		{
  3299 		LOGSMSPROT1("No PDUs in Permanent store file");
  3306 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_GETSMSENTRIESL_2, "No PDUs in Permanent store file");
  3300 		}
  3307 		}
  3301 
  3308 
  3302 	TInt preAllocatedFileIndex=KErrNotFound;
  3309 	TInt preAllocatedFileIndex=KErrNotFound;
  3303 	iPreallocatedFile->MatchEntryToExistingMessage(aEntry, preAllocatedFileIndex);
  3310 	iPreallocatedFile->MatchEntryToExistingMessage(aEntry, preAllocatedFileIndex);
  3304 	if (preAllocatedFileIndex!=KErrNotFound)
  3311 	if (preAllocatedFileIndex!=KErrNotFound)
  3328 
  3335 
  3329 		if (permanentStoreIndex==KErrNotFound)
  3336 		if (permanentStoreIndex==KErrNotFound)
  3330 			{
  3337 			{
  3331 			//In this scenario a CSmsMessage object has to be created from the existing PDU in
  3338 			//In this scenario a CSmsMessage object has to be created from the existing PDU in
  3332 			//pre-allocated file & then serialized into aSmsMessage.
  3339 			//pre-allocated file & then serialized into aSmsMessage.
  3333 			LOGSMSPROT2("Number of PDUs in Pre-allocated file %d", aIndexArray.Count());
  3340 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_GETSMSENTRIESL_3, "Number of PDUs in Pre-allocated file %d", aIndexArray.Count());
  3334 			if (aIndexArray.Count() > 0)
  3341 			if (aIndexArray.Count() > 0)
  3335 				{
  3342 				{
  3336 				CSmsBuffer* smsBuffer = CSmsBuffer::NewL();
  3343 				CSmsBuffer* smsBuffer = CSmsBuffer::NewL();
  3337 				CSmsMessage* smsMessage = CSmsMessage::NewL(iFs, aSmsArray.At(0), smsBuffer, EFalse, ETrue);
  3344 				CSmsMessage* smsMessage = CSmsMessage::NewL(iFs, aSmsArray.At(0), smsBuffer, EFalse, ETrue);
  3338 				CleanupStack::PushL(smsMessage);
  3345 				CleanupStack::PushL(smsMessage);
  3501 /**
  3508 /**
  3502  *  Utility func for cleanup stack
  3509  *  Utility func for cleanup stack
  3503  */
  3510  */
  3504 void CClass0StoreCloseObject(TAny* aObj)
  3511 void CClass0StoreCloseObject(TAny* aObj)
  3505 	{
  3512 	{
  3506 	LOGGSMU2("WARNING! Hey, CClass0StoreCloseObject called by Untrapper! [0x%08x]", aObj);
  3513 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0STORECLOSEOBJECT_1, "WARNING! Hey, CClass0StoreCloseObject called by Untrapper! [0x%08x]", (TUint)aObj);
  3507 	((CClass0SmsReassemblyStore*)aObj)->Revert();
  3514 	((CClass0SmsReassemblyStore*)aObj)->Revert();
  3508 	}
  3515 	}
  3509 
  3516 
  3510 /**
  3517 /**
  3511  *  Sets the class 0 re-assembly store as in-transaction.
  3518  *  Sets the class 0 re-assembly store as in-transaction.
  3514  *  invalid.
  3521  *  invalid.
  3515  *  @capability None
  3522  *  @capability None
  3516  */
  3523  */
  3517 void CClass0SmsReassemblyStore::BeginTransactionLC()
  3524 void CClass0SmsReassemblyStore::BeginTransactionLC()
  3518 	{
  3525 	{
  3519 	LOGSMSPROT3("CClass0SmsReassemblyStore::BeginTransactionLC [this=0x%08X iInTransaction=%d]", this, iInTransaction);
  3526 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_BEGINTRANSACTIONLC_1, "CClass0SmsReassemblyStore::BeginTransactionLC [this=0x%08X iInTransaction=%d]", (TUint)this, iInTransaction);
  3520 
  3527 
  3521 	if (iInTransaction)
  3528 	if (iInTransaction)
  3522 		{
  3529 		{
  3523 	    LOGGSMU1("WARNING CClass0SmsReassemblyStore::BeginTransactionLC leaving with KErrAccessDenied");
  3530 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_BEGINTRANSACTIONLC_2, "WARNING CClass0SmsReassemblyStore::BeginTransactionLC leaving with KErrAccessDenied");
  3524 		User::Leave(KErrAccessDenied);
  3531 		User::Leave(KErrAccessDenied);
  3525 		}
  3532 		}
  3526 
  3533 
  3527 	TCleanupItem class0StoreClose(CClass0StoreCloseObject, this);
  3534 	TCleanupItem class0StoreClose(CClass0StoreCloseObject, this);
  3528 	CleanupStack::PushL(class0StoreClose);
  3535 	CleanupStack::PushL(class0StoreClose);
  3534 /**
  3541 /**
  3535  *  It commits the transaction.
  3542  *  It commits the transaction.
  3536  */
  3543  */
  3537 void CClass0SmsReassemblyStore::CommitTransactionL()
  3544 void CClass0SmsReassemblyStore::CommitTransactionL()
  3538 	{
  3545 	{
  3539 	LOGSMSPROT3("CClass0SmsReassemblyStore::CommitTransactionL(): this=0x%08X iInTransaction=%d",
  3546 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_COMMITTRANSACTIONL_1, "CClass0SmsReassemblyStore::CommitTransactionL(): this=0x%08X iInTransaction=%d",(TUint)this, iInTransaction);
  3540 				this, iInTransaction);
       
  3541 
  3547 
  3542 	//Commit permanent store file
  3548 	//Commit permanent store file
  3543 	iPermanentFileStore->CommitTransactionL();
  3549 	iPermanentFileStore->CommitTransactionL();
  3544 	//Commit pre-allocated file
  3550 	//Commit pre-allocated file
  3545 	iPreallocatedFile->CommitTransactionL();
  3551 	iPreallocatedFile->CommitTransactionL();
  3550 /**
  3556 /**
  3551  *  It reverts the transaction.
  3557  *  It reverts the transaction.
  3552  */
  3558  */
  3553 void CClass0SmsReassemblyStore::Revert()
  3559 void CClass0SmsReassemblyStore::Revert()
  3554 	{
  3560 	{
  3555 	LOGSMSPROT3("CClass0SmsReassemblyStore::Revert(): this=0x%08X, iInTransaction=%d",
  3561 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CCLASS0SMSREASSEMBLYSTORE_REVERT_1, "CClass0SmsReassemblyStore::Revert(): this=0x%08X, iInTransaction=%d",(TUint)this, iInTransaction);
  3556     		 this, iInTransaction);
       
  3557 
  3562 
  3558 	iPreallocatedFile->Revert();
  3563 	iPreallocatedFile->Revert();
  3559 	iPermanentFileStore->Revert();
  3564 	iPermanentFileStore->Revert();
  3560 	iInTransaction = EFalse;
  3565 	iInTransaction = EFalse;
  3561 	}
  3566 	}