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