smsprotocols/smsstack/smsprot/Src/smspstor.cpp
branchRCL_3
changeset 20 07a122eea281
parent 19 630d2f34d719
equal deleted inserted replaced
19:630d2f34d719 20:07a122eea281
     1 // Copyright (c) 1999-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1999-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".
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
    21 
    21 
    22 
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "smspstorTraces.h"
       
    26 #endif
       
    27 
       
    28 #include <e32svr.h>
    22 #include <e32svr.h>
    29 #include <es_ini.h>
    23 #include <es_ini.h>
    30 #include "smspstor.h"
    24 #include "smspstor.h"
    31 #include "smspmain.h"
    25 #include "smspmain.h"
    32 #include "smsuaddr.H"
    26 #include "smsuaddr.H"
    33 #include "Gsmumsg.h"
    27 #include "Gsmumsg.h"
    34 #include "gsmubuf.h"
    28 #include "gsmubuf.h"
       
    29 #include <logwrap.h>
    35 #include <logwraplimits.h>
    30 #include <logwraplimits.h>
    36 #include "Gsmuelem.h"
    31 #include "Gsmuelem.h"
    37 #include "gsmuieoperations.h"
    32 #include "gsmuieoperations.h"
    38 #include "gsmunonieoperations.h"
    33 #include "gsmunonieoperations.h"
    39 
    34 
    40 LOCAL_C TPtrC TrimLeadingZeros(const TDesC& aString)
    35 LOCAL_C TPtrC TrimLeadingZeros(const TDesC& aString)
    41 	{
    36 	{
    42 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, TRIMLEADINGZEROS_1, "CSARStore::ExternalizeEntryArrayL()");
    37 	LOGSMSPROT1("CSARStore::ExternalizeEntryArrayL()");
    43 
    38 
    44 	const TInt len = aString.Length();
    39 	const TInt len = aString.Length();
    45 
    40 
    46 	if (len == 0)
    41 	if (len == 0)
    47 		return aString;
    42 		return aString;
    62  *  
    57  *  
    63  *  @param aFs  File Server handle.
    58  *  @param aFs  File Server handle.
    64  */
    59  */
    65 CSmsReassemblyStore* CSmsReassemblyStore::NewL(RFs& aFs)
    60 CSmsReassemblyStore* CSmsReassemblyStore::NewL(RFs& aFs)
    66 	{
    61 	{
    67 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_NEWL_1, "CSmsReassemblyStore::NewL()");
    62 	LOGSMSPROT1("CSmsReassemblyStore::NewL()");
    68 
    63 
    69 	CSmsReassemblyStore*  self = new (ELeave) CSmsReassemblyStore(aFs);
    64 	CSmsReassemblyStore*  self = new (ELeave) CSmsReassemblyStore(aFs);
    70 	CleanupStack::PushL(self);
    65 	CleanupStack::PushL(self);
    71 	self->ConstructL();
    66 	self->ConstructL();
    72 	CleanupStack::Pop(self);
    67 	CleanupStack::Pop(self);
    78 /**
    73 /**
    79  *  Creates and starts timer
    74  *  Creates and starts timer
    80  */
    75  */
    81 void CSmsReassemblyStore::ConstructL()
    76 void CSmsReassemblyStore::ConstructL()
    82 	{
    77 	{
    83 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_CONSTRUCTL_1, "CSmsReassemblyStore::ConstructL()");
    78 	LOGSMSPROT1("CSmsReassemblyStore::ConstructL()");
    84 
    79 
    85 	//
    80 	//
    86 	// Generate the full path to the reassembly store.
    81 	// Generate the full path to the reassembly store.
    87 	//
    82 	//
    88 	PrivatePath(iFullPathBuf);
    83 	PrivatePath(iFullPathBuf);
   102 	} // CSmsReassemblyStore::~CSmsReassemblyStore
    97 	} // CSmsReassemblyStore::~CSmsReassemblyStore
   103 
    98 
   104 
    99 
   105 void CSmsReassemblyStore::UpdateLogServerIdL(TInt aIndex, TLogId aLogServerId)
   100 void CSmsReassemblyStore::UpdateLogServerIdL(TInt aIndex, TLogId aLogServerId)
   106 	{
   101 	{
   107 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_UPDATELOGSERVERIDL_1, "CSmsReassemblyStore::UpdateLogServerIdL()");
   102 	LOGSMSPROT1("CSmsReassemblyStore::UpdateLogServerIdL()");
   108 
   103 
   109 	TSmsReassemblyEntry entry(reinterpret_cast<const TSmsReassemblyEntry&>(Entries()[aIndex]));
   104 	TSmsReassemblyEntry entry(reinterpret_cast<const TSmsReassemblyEntry&>(Entries()[aIndex]));
   110 
   105 
   111 	if (entry.LogServerId() != aLogServerId)
   106 	if (entry.LogServerId() != aLogServerId)
   112 		{
   107 		{
   130  */
   125  */
   131 TBool CSmsReassemblyStore::FindMessageL(const CSmsMessage& aSmsMessage,
   126 TBool CSmsReassemblyStore::FindMessageL(const CSmsMessage& aSmsMessage,
   132 										TBool aPassed,
   127 										TBool aPassed,
   133 										TInt& aIndex)
   128 										TInt& aIndex)
   134  	{
   129  	{
   135  	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_FINDMESSAGEL_1, "CSmsReassemblyStore::FindMessageL()");
   130  	LOGSMSPROT1("CSmsReassemblyStore::FindMessageL()");
   136 
   131 
   137 	//
   132 	//
   138 	// Parse the GSM data from the SMS message...
   133 	// Parse the GSM data from the SMS message...
   139 	//
   134 	//
   140 	TGsmSmsTelNumber  parsedAddress;
   135 	TGsmSmsTelNumber  parsedAddress;
   156 			entry.Description2().Right(8) == parsedAddress.iTelNumber.Right(8))
   151 			entry.Description2().Right(8) == parsedAddress.iTelNumber.Right(8))
   157  			{
   152  			{
   158 			//
   153 			//
   159 			// Found!
   154 			// Found!
   160 			//
   155 			//
   161 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_FINDMESSAGEL_2, "CSmsReassemblyStore::FindMessage(): Found! index=%d", index);
   156 			LOGSMSPROT2("CSmsReassemblyStore::FindMessage(): Found! index=%d", index);
   162 
   157 
   163 			aIndex = index;
   158 			aIndex = index;
   164 
   159 
   165 			return ETrue;
   160 			return ETrue;
   166 			}
   161 			}
   167  		}
   162  		}
   168 
   163 
   169 	//
   164 	//
   170 	// Not found...
   165 	// Not found...
   171 	//
   166 	//
   172 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_FINDMESSAGEL_3, "CSmsReassemblyStore::FindMessage(): Not found!");
   167 	LOGSMSPROT1("CSmsReassemblyStore::FindMessage(): Not found!");
   173 
   168 
   174  	return EFalse;
   169  	return EFalse;
   175  	} // CSmsReassemblyStore::FindMessageL
   170  	} // CSmsReassemblyStore::FindMessageL
   176 
   171 
   177 
   172 
   185  *  @param aServiceCenterAddressPresent Used to
   180  *  @param aServiceCenterAddressPresent Used to
   186  */
   181  */
   187 void CSmsReassemblyStore::MatchPDUToExistingMessage(const CSmsMessage& aSmsMessage,
   182 void CSmsReassemblyStore::MatchPDUToExistingMessage(const CSmsMessage& aSmsMessage,
   188 													TInt& aIndex)
   183 													TInt& aIndex)
   189 	{
   184 	{
   190 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_MATCHPDUTOEXISTINGMESSAGE_1, "CSmsReassemblyStore::MatchPDUToExistingMessage()");
   185 	LOGSMSPROT1("CSmsReassemblyStore::MatchPDUToExistingMessage()");
   191 
   186 
   192 	__ASSERT_ALWAYS(!aSmsMessage.IsDecoded(), SmspPanic(KSmspPanicMessageConcatenated));
   187 	__ASSERT_ALWAYS(!aSmsMessage.IsDecoded(), SmspPanic(KSmspPanicMessageConcatenated));
   193 
   188 
   194 	aIndex = KErrNotFound;
   189 	aIndex = KErrNotFound;
   195 
   190 
   225 				break;
   220 				break;
   226 				}
   221 				}
   227 			}
   222 			}
   228 		}
   223 		}
   229 
   224 
   230 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_MATCHPDUTOEXISTINGMESSAGE_2, "CSmsReassemblyStore::MatchPDUToExistingMessage(): reassemblyCount=%d, aIndex=%d", reassemblyCount, aIndex);
   225 	LOGSMSPROT3("CSmsReassemblyStore::MatchPDUToExistingMessage(): reassemblyCount=%d, aIndex=%d", reassemblyCount, aIndex);
   231 	} // CSmsReassemblyStore::MatchPDUToExistingMessage
   226 	} // CSmsReassemblyStore::MatchPDUToExistingMessage
   232 
   227 
   233 
   228 
   234 void CSmsReassemblyStore::UpdateExistingMessageL(const CSmsMessage& aSmsMessage,
   229 void CSmsReassemblyStore::UpdateExistingMessageL(const CSmsMessage& aSmsMessage,
   235 												 const TGsmSms& aGsmSms, TInt aIndex,
   230 												 const TGsmSms& aGsmSms, TInt aIndex,
   236 												 TBool& aComplete,
   231 												 TBool& aComplete,
   237 												 TBool& aDuplicateMsgRef,
   232 												 TBool& aDuplicateMsgRef,
   238 												 TBool& aDuplicateSlot)
   233 												 TBool& aDuplicateSlot)
   239 	{
   234 	{
   240 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_UPDATEEXISTINGMESSAGEL_1, "CSmsReassemblyStore::UpdateExistingMessageL()");
   235 	LOGSMSPROT1("CSmsReassemblyStore::UpdateExistingMessageL()");
   241 
   236 
   242 	aComplete        = EFalse;
   237 	aComplete        = EFalse;
   243 	aDuplicateMsgRef = EFalse;
   238 	aDuplicateMsgRef = EFalse;
   244 	aDuplicateSlot   = EFalse;
   239 	aDuplicateSlot   = EFalse;
   245 
   240 
   279 			{
   274 			{
   280 			const TGsmSmsSlotEntry&  slot = smsMessage->iSlotArray[slotNum];
   275 			const TGsmSmsSlotEntry&  slot = smsMessage->iSlotArray[slotNum];
   281 
   276 
   282 			if (slot.iIndex == newSlot.iIndex  && slot.iStore == newSlot.iStore)
   277 			if (slot.iIndex == newSlot.iIndex  && slot.iStore == newSlot.iStore)
   283 				{
   278 				{
   284 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_UPDATEEXISTINGMESSAGEL_2, "CSmsReassemblyStore::UpdateExistingMessageL(): Duplicate enumerated PDU.");
   279 				LOGSMSPROT1("CSmsReassemblyStore::UpdateExistingMessageL(): Duplicate enumerated PDU.");
   285 
   280 
   286 				// It is a duplicate that was already stored on the SIM...
   281 				// It is a duplicate that was already stored on the SIM...
   287 				aDuplicateSlot = ETrue;
   282 				aDuplicateSlot = ETrue;
   288 				break;
   283 				break;
   289 				}
   284 				}
   294 
   289 
   295 	for (TInt index = 0;  index < indexArrayCount;  index++ )
   290 	for (TInt index = 0;  index < indexArrayCount;  index++ )
   296 		{
   291 		{
   297 		if (indexArray->At(index) == concatPDUIndex)
   292 		if (indexArray->At(index) == concatPDUIndex)
   298 			{
   293 			{
   299 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_UPDATEEXISTINGMESSAGEL_3, "CSmsReassemblyStore::UpdateExistingMessageL(): Duplicate concatenated PDU.");
   294 			LOGSMSPROT1("CSmsReassemblyStore::UpdateExistingMessageL(): Duplicate concatenated PDU.");
   300 
   295 
   301 			// The PDU is already stored in the reassembly store.
   296 			// The PDU is already stored in the reassembly store.
   302 			aDuplicateMsgRef = ETrue;
   297 			aDuplicateMsgRef = ETrue;
   303 			break;
   298 			break;
   304 			}
   299 			}
   363 	} // CSmsReassemblyStore::UpdateExistingMessageL
   358 	} // CSmsReassemblyStore::UpdateExistingMessageL
   364 
   359 
   365 
   360 
   366 void CSmsReassemblyStore::NewMessagePDUL(TInt& aIndex,CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms)
   361 void CSmsReassemblyStore::NewMessagePDUL(TInt& aIndex,CSmsMessage& aSmsMessage,const TGsmSms& aGsmSms)
   367 	{
   362 	{
   368 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_NEWMESSAGEPDUL_1, "CSmsReassemblyStore::NewMessagePDUL");
   363 	LOGSMSPROT1("CSmsReassemblyStore::NewMessagePDUL");
   369 
   364 
   370 	CArrayFix<TInt>* indexarray=new(ELeave) CArrayFixFlat<TInt>(8);
   365 	CArrayFix<TInt>* indexarray=new(ELeave) CArrayFixFlat<TInt>(8);
   371 	CleanupStack::PushL(indexarray);
   366 	CleanupStack::PushL(indexarray);
   372 	CArrayFixFlat<TGsmSms>* smsarray=new(ELeave) CArrayFixFlat<TGsmSms>(8);
   367 	CArrayFixFlat<TGsmSms>* smsarray=new(ELeave) CArrayFixFlat<TGsmSms>(8);
   373 	CleanupStack::PushL(smsarray);
   368 	CleanupStack::PushL(smsarray);
   380 	} // CSmsReassemblyStore::NewMessagePDUL
   375 	} // CSmsReassemblyStore::NewMessagePDUL
   381 
   376 
   382 
   377 
   383 void CSmsReassemblyStore::GetMessageL(TInt aIndex,CSmsMessage& aSmsMessage)
   378 void CSmsReassemblyStore::GetMessageL(TInt aIndex,CSmsMessage& aSmsMessage)
   384 	{
   379 	{
   385 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_GETMESSAGEL_1, "CSmsReassemblyStore::GetMessageL [aIndex=%d]", aIndex);
   380 	LOGSMSPROT2("CSmsReassemblyStore::GetMessageL [aIndex=%d]", aIndex);
   386 
   381 
   387 	CArrayFix<TInt>* indexarray=new(ELeave) CArrayFixFlat<TInt>(8);
   382 	CArrayFix<TInt>* indexarray=new(ELeave) CArrayFixFlat<TInt>(8);
   388 	CleanupStack::PushL(indexarray);
   383 	CleanupStack::PushL(indexarray);
   389 	CArrayFixFlat<TGsmSms>* smsarray=new(ELeave) CArrayFixFlat<TGsmSms>(8);
   384 	CArrayFixFlat<TGsmSms>* smsarray=new(ELeave) CArrayFixFlat<TGsmSms>(8);
   390 	CleanupStack::PushL(smsarray);
   385 	CleanupStack::PushL(smsarray);
   401  *  
   396  *  
   402  *  NOTE! You have to call CSARStore::OpenFileLC() before calling this function
   397  *  NOTE! You have to call CSARStore::OpenFileLC() before calling this function
   403  */
   398  */
   404 void CSmsReassemblyStore::InternalizeEntryL(const TStreamId& aStreamId,CSmsMessage& aSmsMessage,CArrayFix<TInt>& aIndexArray,CArrayFix<TGsmSms>& aSmsArray)
   399 void CSmsReassemblyStore::InternalizeEntryL(const TStreamId& aStreamId,CSmsMessage& aSmsMessage,CArrayFix<TInt>& aIndexArray,CArrayFix<TGsmSms>& aSmsArray)
   405 	{
   400 	{
   406 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_INTERNALIZEENTRYL_1, "CSmsReassemblyStore::InternalizeEntryL Start [sid=%d]", aStreamId.Value());
   401 	LOGSMSPROT2("CSmsReassemblyStore::InternalizeEntryL Start [sid=%d]", aStreamId.Value());
   407 	RStoreReadStream readstream;
   402 	RStoreReadStream readstream;
   408 	readstream.OpenLC(FileStore(),aStreamId);
   403 	readstream.OpenLC(FileStore(),aStreamId);
   409 	readstream >> aSmsMessage;
   404 	readstream >> aSmsMessage;
   410 	TInt count=readstream.ReadInt32L();
   405 	TInt count=readstream.ReadInt32L();
   411 	aIndexArray.Reset();
   406 	aIndexArray.Reset();
   426 		TGsmSms sms;
   421 		TGsmSms sms;
   427 		sms.SetPdu(pdu);
   422 		sms.SetPdu(pdu);
   428 		aSmsArray.AppendL(sms);
   423 		aSmsArray.AppendL(sms);
   429 		}
   424 		}
   430 	CleanupStack::PopAndDestroy();
   425 	CleanupStack::PopAndDestroy();
   431 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_INTERNALIZEENTRYL_2, "CSmsReassemblyStore::InternalizeEntryL End [count=%d]", count);
   426 	LOGSMSPROT2("CSmsReassemblyStore::InternalizeEntryL End [count=%d]", count);
   432 	} // CSARStore::OpenFileLC
   427 	} // CSARStore::OpenFileLC
   433 
   428 
   434 
   429 
   435 /**
   430 /**
   436  *  externalizes all the entries from the internal memory to the permanent file store
   431  *  externalizes all the entries from the internal memory to the permanent file store
   437  *  
   432  *  
   438  *  NOTE! You have to call CSARStore::OpenFileLC() before calling this function
   433  *  NOTE! You have to call CSARStore::OpenFileLC() before calling this function
   439  */
   434  */
   440 void CSmsReassemblyStore::ExternalizeEntryL(TStreamId& aStreamId,const CSmsMessage& aSmsMessage,const CArrayFix<TInt>& aIndexArray,const CArrayFix<TGsmSms>& aSmsArray)
   435 void CSmsReassemblyStore::ExternalizeEntryL(TStreamId& aStreamId,const CSmsMessage& aSmsMessage,const CArrayFix<TInt>& aIndexArray,const CArrayFix<TGsmSms>& aSmsArray)
   441 	{
   436 	{
   442 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_EXTERNALIZEENTRYL_1, "CSmsReassemblyStore::ExternalizeEntryL Start [sid=%d]", aStreamId.Value());
   437 	LOGSMSPROT2("CSmsReassemblyStore::ExternalizeEntryL Start [sid=%d]", aStreamId.Value());
   443 
   438 
   444 	RStoreWriteStream writestream;
   439 	RStoreWriteStream writestream;
   445 	if (aStreamId==KNullStreamId)
   440 	if (aStreamId==KNullStreamId)
   446 		aStreamId=writestream.CreateLC(FileStore());
   441 		aStreamId=writestream.CreateLC(FileStore());
   447 	else
   442 	else
   462 		writestream << pdu;
   457 		writestream << pdu;
   463 		}
   458 		}
   464 	writestream.CommitL();
   459 	writestream.CommitL();
   465 	CleanupStack::PopAndDestroy();
   460 	CleanupStack::PopAndDestroy();
   466 
   461 
   467 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_EXTERNALIZEENTRYL_2, "CSmsReassemblyStore::ExternalizeEntryL End [count=%d]", count);
   462 	LOGSMSPROT2("CSmsReassemblyStore::ExternalizeEntryL End [count=%d]", count);
   468 	} // CSARStore::OpenFileLC
   463 	} // CSARStore::OpenFileLC
   469 
   464 
   470 
   465 
   471 void CSmsReassemblyStore::PopulateEntry(TSmsReassemblyEntry& aEntry,const CSmsMessage& aSmsMessage,TInt aNumSmss)
   466 void CSmsReassemblyStore::PopulateEntry(TSmsReassemblyEntry& aEntry,const CSmsMessage& aSmsMessage,TInt aNumSmss)
   472 	{
   467 	{
   473 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_POPULATEENTRY_1, "CSmsReassemblyStore::PopulateEntry");
   468 	LOGSMSPROT1("CSmsReassemblyStore::PopulateEntry");
   474 	aEntry.SetReference(0);
   469 	aEntry.SetReference(0);
   475 	aEntry.SetTotal(1);
   470 	aEntry.SetTotal(1);
   476 	aEntry.SetCount(1);
   471 	aEntry.SetCount(1);
   477 
   472 
   478 	if (aSmsMessage.TextPresent())
   473 	if (aSmsMessage.TextPresent())
   526 	} // CSmsReassemblyStore::PopulateEntry
   521 	} // CSmsReassemblyStore::PopulateEntry
   527 
   522 
   528 
   523 
   529 void CSmsReassemblyStore::CreateEntryL(CSmsMessage& aSmsMessage,const CArrayFix<TInt>& aIndexArray,const CArrayFix<TGsmSms>& aSmsArray)
   524 void CSmsReassemblyStore::CreateEntryL(CSmsMessage& aSmsMessage,const CArrayFix<TInt>& aIndexArray,const CArrayFix<TGsmSms>& aSmsArray)
   530 	{
   525 	{
   531 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_CREATEENTRYL_1, "CSmsReassemblyStore::CreateEntryL");
   526 	LOGSMSPROT1("CSmsReassemblyStore::CreateEntryL");
   532  	TStreamId streamid=KNullStreamId;
   527  	TStreamId streamid=KNullStreamId;
   533  	if (aSmsMessage.Time() >= iLastRealTime)
   528  	if (aSmsMessage.Time() >= iLastRealTime)
   534  		{
   529  		{
   535  		iLastRealTime=aSmsMessage.Time();
   530  		iLastRealTime=aSmsMessage.Time();
   536  		if(iLastReceivedTime >= aSmsMessage.Time())
   531  		if(iLastReceivedTime >= aSmsMessage.Time())
   554 	} // CSmsReassemblyStore::CreateEntryL
   549 	} // CSmsReassemblyStore::CreateEntryL
   555 
   550 
   556 
   551 
   557 TBool CSmsReassemblyStore::PassedToClient( TInt aIndex ) const
   552 TBool CSmsReassemblyStore::PassedToClient( TInt aIndex ) const
   558 	{
   553 	{
   559 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_PASSEDTOCLIENT_1, "CSmsReassemblyStore::PassedToClient()");
   554 	LOGSMSPROT1("CSmsReassemblyStore::PassedToClient()");
   560 
   555 
   561 	const TSmsReassemblyEntry& entry = reinterpret_cast<const TSmsReassemblyEntry&>(Entries()[ aIndex ]);
   556 	const TSmsReassemblyEntry& entry = reinterpret_cast<const TSmsReassemblyEntry&>(Entries()[ aIndex ]);
   562 	return entry.PassedToClient();
   557 	return entry.PassedToClient();
   563 	} // CSmsReassemblyStore::PassedToClient
   558 	} // CSmsReassemblyStore::PassedToClient
   564 
   559 
   565 
   560 
   566 void CSmsReassemblyStore::SetPassedToClientL(TInt aIndex, TBool aPassed)
   561 void CSmsReassemblyStore::SetPassedToClientL(TInt aIndex, TBool aPassed)
   567 	{
   562 	{
   568 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_SETPASSEDTOCLIENTL_1, "CSmsReassemblyStore::SetPassedToClientL()");
   563 	LOGSMSPROT1("CSmsReassemblyStore::SetPassedToClientL()");
   569 
   564 
   570 	TSmsReassemblyEntry entry(reinterpret_cast<const TSmsReassemblyEntry&>(Entries()[aIndex]));
   565 	TSmsReassemblyEntry entry(reinterpret_cast<const TSmsReassemblyEntry&>(Entries()[aIndex]));
   571 
   566 
   572 	const TBool alreadyPassed = entry.PassedToClient();
   567 	const TBool alreadyPassed = entry.PassedToClient();
   573 
   568 
   582 /**
   577 /**
   583  *  Open the sms reassembly store.
   578  *  Open the sms reassembly store.
   584  */
   579  */
   585 void CSmsReassemblyStore::OpenStoreL()
   580 void CSmsReassemblyStore::OpenStoreL()
   586 	{
   581 	{
   587 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSREASSEMBLYSTORE_OPENSTOREL_1, "CSmsReassemblyStore::OpenStoreL()");
   582 	LOGSMSPROT1("CSmsReassemblyStore::OpenStoreL()");
   588 
   583 
   589 	this->OpenL(iFullPathBuf,KReassemblyStoreUid);
   584 	this->OpenL(iFullPathBuf,KReassemblyStoreUid);
   590 	} // CSmsReassemblyStore::OpenStoreL
   585 	} // CSmsReassemblyStore::OpenStoreL
   591 
   586 
   592 
   587 
   602 	} // CSmsReassemblyStore::CSmsReassemblyStore
   597 	} // CSmsReassemblyStore::CSmsReassemblyStore
   603 
   598 
   604 
   599 
   605 CSmsSegmentationStore* CSmsSegmentationStore::NewL(RFs& aFs)
   600 CSmsSegmentationStore* CSmsSegmentationStore::NewL(RFs& aFs)
   606 	{
   601 	{
   607 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_NEWL_1, "CSmsSegmentationStore::NewL()");
   602 	LOGSMSPROT1("CSmsSegmentationStore::NewL()");
   608 
   603 
   609 	CSmsSegmentationStore* segmentationStore = new(ELeave) CSmsSegmentationStore(aFs);
   604 	CSmsSegmentationStore* segmentationStore = new(ELeave) CSmsSegmentationStore(aFs);
   610 	CleanupStack::PushL( segmentationStore );
   605 	CleanupStack::PushL( segmentationStore );
   611 	segmentationStore->ConstructL();
   606 	segmentationStore->ConstructL();
   612 	CleanupStack::Pop( segmentationStore );
   607 	CleanupStack::Pop( segmentationStore );
   614 	} // CSmsSegmentationStore::NewL
   609 	} // CSmsSegmentationStore::NewL
   615 
   610 
   616 
   611 
   617 void CSmsSegmentationStore::ConstructL()
   612 void CSmsSegmentationStore::ConstructL()
   618 	{
   613 	{
   619 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_CONSTRUCTL_1, "CSmsSegmentationStore::ConstructL()");
   614 	LOGSMSPROT1("CSmsSegmentationStore::ConstructL()");
   620 
   615 
   621 	//generate fullpath of segmentation store.
   616 	//generate fullpath of segmentation store.
   622 	PrivatePath(iFullPathBuf);
   617 	PrivatePath(iFullPathBuf);
   623 	//append store name
   618 	//append store name
   624 	iFullPathBuf.Append(KSegmentationStoreName);
   619 	iFullPathBuf.Append(KSegmentationStoreName);
   655     } // CSmsSegmentationStore::~CSmsSegmentationStore
   650     } // CSmsSegmentationStore::~CSmsSegmentationStore
   656 
   651 
   657 
   652 
   658 TInt CSmsSegmentationStore::Next8BitReferenceL()
   653 TInt CSmsSegmentationStore::Next8BitReferenceL()
   659 	{
   654 	{
   660 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_NEXT8BITREFERENCEL_1, "CSmsSegmentationStore::Next8BitReferenceL");
   655 	LOGSMSPROT1("CSmsSegmentationStore::Next8BitReferenceL");
   661 
   656 
   662 	TInt reference8bit=0;
   657 	TInt reference8bit=0;
   663 	TInt reference16bit=0;
   658 	TInt reference16bit=0;
   664 	TStreamId streamid=ExtraStreamId();
   659 	TStreamId streamid=ExtraStreamId();
   665 
   660 
   672 		TRAPD(ret,InternalizeConcatenationReferencesL(streamid,reference8bit,reference16bit));
   667 		TRAPD(ret,InternalizeConcatenationReferencesL(streamid,reference8bit,reference16bit));
   673 		if(ret != KErrNone)
   668 		if(ret != KErrNone)
   674 			{
   669 			{
   675 			// We have to leave on any error; otherwise a duplicate reference number will be generated
   670 			// We have to leave on any error; otherwise a duplicate reference number will be generated
   676 			// The transaction will revert
   671 			// The transaction will revert
   677 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_NEXT8BITREFERENCEL_2, "WARNING! CSmsSegmentationStore::InternalizeConcatenationReferencesL left with %d", ret);
   672 			LOGSMSPROT2("WARNING! CSmsSegmentationStore::InternalizeConcatenationReferencesL left with %d", ret);
   678 			User::Leave(ret);  //  stream not corrupted
   673 			User::Leave(ret);  //  stream not corrupted
   679 			}
   674 			}
   680 		reference8bit=(reference8bit+1)%0x100;
   675 		reference8bit=(reference8bit+1)%0x100;
   681 		}
   676 		}
   682 	TRAPD(ret, ExternalizeConcatenationReferencesL(streamid,reference8bit,reference16bit));
   677 	TRAPD(ret, ExternalizeConcatenationReferencesL(streamid,reference8bit,reference16bit));
   683 	if(ret != KErrNone)
   678 	if(ret != KErrNone)
   684 		{
   679 		{
   685 		// We have to leave on any error; otherwise a duplicate reference number will be generated
   680 		// We have to leave on any error; otherwise a duplicate reference number will be generated
   686 		// The transaction will revert
   681 		// The transaction will revert
   687 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_NEXT8BITREFERENCEL_3, "WARNING! CSmsSegmentationStore::ExternalizeConcatenationReferencesL left with %d", ret);
   682 		LOGSMSPROT2("WARNING! CSmsSegmentationStore::ExternalizeConcatenationReferencesL left with %d", ret);
   688 		User::Leave(ret);  //  stream not corrupted
   683 		User::Leave(ret);  //  stream not corrupted
   689 		}
   684 		}
   690 	SetExtraStreamIdL(streamid);
   685 	SetExtraStreamIdL(streamid);
   691 	CommitTransactionL();
   686 	CommitTransactionL();
   692 	return reference8bit;
   687 	return reference8bit;
   693 	} // CSmsSegmentationStore::Next8BitReferenceL
   688 	} // CSmsSegmentationStore::Next8BitReferenceL
   694 
   689 
   695 
   690 
   696 TInt CSmsSegmentationStore::Next16BitReferenceL()
   691 TInt CSmsSegmentationStore::Next16BitReferenceL()
   697 	{
   692 	{
   698 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_NEXT16BITREFERENCEL_1, "CSmsSegmentationStore::Next16BitReferenceL");
   693 	LOGSMSPROT1("CSmsSegmentationStore::Next16BitReferenceL");
   699 	TInt reference8bit=0;
   694 	TInt reference8bit=0;
   700 	TInt reference16bit=0x100;
   695 	TInt reference16bit=0x100;
   701 	TStreamId streamid=ExtraStreamId();
   696 	TStreamId streamid=ExtraStreamId();
   702 	//
   697 	//
   703 	// access file store
   698 	// access file store
   708 		TRAPD(ret,InternalizeConcatenationReferencesL(streamid,reference8bit,reference16bit));
   703 		TRAPD(ret,InternalizeConcatenationReferencesL(streamid,reference8bit,reference16bit));
   709 		if(ret != KErrNone)
   704 		if(ret != KErrNone)
   710 			{
   705 			{
   711 			// We have to leave on any error; otherwise a duplicate reference number will be generated
   706 			// We have to leave on any error; otherwise a duplicate reference number will be generated
   712 			// The transaction will revert
   707 			// The transaction will revert
   713 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_NEXT16BITREFERENCEL_2, "WARNING! CSmsSegmentationStore::InternalizeConcatenationReferencesL left with %d", ret);
   708 			LOGSMSPROT2("WARNING! CSmsSegmentationStore::InternalizeConcatenationReferencesL left with %d", ret);
   714 			User::Leave(ret);  //  stream not corrupted
   709 			User::Leave(ret);  //  stream not corrupted
   715 			}
   710 			}
   716 		reference16bit=((reference16bit+1)%0xFF00)+0x100;
   711 		reference16bit=((reference16bit+1)%0xFF00)+0x100;
   717 		}
   712 		}
   718 	TRAPD(ret, ExternalizeConcatenationReferencesL(streamid,reference8bit,reference16bit));
   713 	TRAPD(ret, ExternalizeConcatenationReferencesL(streamid,reference8bit,reference16bit));
   719 	if(ret != KErrNone)
   714 	if(ret != KErrNone)
   720 		{
   715 		{
   721 		// We have to leave on any error; otherwise a duplicate reference number will be generated
   716 		// We have to leave on any error; otherwise a duplicate reference number will be generated
   722 		// The transaction will revert
   717 		// The transaction will revert
   723 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_NEXT16BITREFERENCEL_3, "WARNING! CSmsSegmentationStore::ExternalizeConcatenationReferencesL left with %d", ret);
   718 		LOGSMSPROT2("WARNING! CSmsSegmentationStore::ExternalizeConcatenationReferencesL left with %d", ret);
   724 		User::Leave(ret);  //  stream not corrupted
   719 		User::Leave(ret);  //  stream not corrupted
   725 		}
   720 		}
   726 	SetExtraStreamIdL(streamid);
   721 	SetExtraStreamIdL(streamid);
   727 	CommitTransactionL();
   722 	CommitTransactionL();
   728 	return reference16bit;
   723 	return reference16bit;
   738  *  @pre aSubmit.Type() is ESmsSubmit
   733  *  @pre aSubmit.Type() is ESmsSubmit
   739  *  @pre aSubmit.EncodeMessagePdusL() has been called. This is so PopulateEntry sets the correct total on the TSAREntry
   734  *  @pre aSubmit.EncodeMessagePdusL() has been called. This is so PopulateEntry sets the correct total on the TSAREntry
   740  */
   735  */
   741 void CSmsSegmentationStore::AddSubmitL(const TSmsAddr& aSmsAddr,CSmsMessage& aSubmit)
   736 void CSmsSegmentationStore::AddSubmitL(const TSmsAddr& aSmsAddr,CSmsMessage& aSubmit)
   742 	{
   737 	{
   743 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSUBMITL_1, "CSmsSegmentationStore::AddSubmitL");
   738 	LOGSMSPROT1("CSmsSegmentationStore::AddSubmitL");
   744 
   739 
   745 	__ASSERT_ALWAYS(aSubmit.Type()==CSmsPDU::ESmsSubmit,SmspPanic(KSmspPanicNotSubmit));
   740 	__ASSERT_ALWAYS(aSubmit.Type()==CSmsPDU::ESmsSubmit,SmspPanic(KSmspPanicNotSubmit));
   746 
   741 
   747 	BeginTransactionLC();
   742 	BeginTransactionLC();
   748 
   743 
   769 	} // CSmsSegmentationStore::AddSubmitL
   764 	} // CSmsSegmentationStore::AddSubmitL
   770 
   765 
   771 
   766 
   772 TBool CSmsSegmentationStore::AddCommandL(const TSmsAddr& aSmsAddr,const CSmsMessage& aCommand, CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray& aRefStatus)
   767 TBool CSmsSegmentationStore::AddCommandL(const TSmsAddr& aSmsAddr,const CSmsMessage& aCommand, CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray& aRefStatus)
   773 	{
   768 	{
   774 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDCOMMANDL_1, "CSmsSegmentationStore::AddCommandL");
   769 	LOGSMSPROT1("CSmsSegmentationStore::AddCommandL");
   775 	__ASSERT_ALWAYS(aCommand.Type()==CSmsPDU::ESmsCommand,SmspPanic(KSmspPanicNotCommand));
   770 	__ASSERT_ALWAYS(aCommand.Type()==CSmsPDU::ESmsCommand,SmspPanic(KSmspPanicNotCommand));
   776 	const TInt count=Entries().Count();
   771 	const TInt count=Entries().Count();
   777 	const TLogId logid=(TLogId) aCommand.LogServerId();
   772 	const TLogId logid=(TLogId) aCommand.LogServerId();
   778 
   773 
   779 	BeginTransactionLC();
   774 	BeginTransactionLC();
   845 
   840 
   846 
   841 
   847 TBool CSmsSegmentationStore::AddReferenceL(const CSmsMessage& aSmsMessage,TInt aReference)
   842 TBool CSmsSegmentationStore::AddReferenceL(const CSmsMessage& aSmsMessage,TInt aReference)
   848 	{
   843 	{
   849 	const TInt count=Entries().Count();
   844 	const TInt count=Entries().Count();
   850 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDREFERENCEL_1, "CSmsSegmentationStore::AddReferenceL [count=%d, ref=%d]", count, aReference);
   845 	LOGSMSPROT3("CSmsSegmentationStore::AddReferenceL [count=%d, ref=%d]", count, aReference);
   851 	TInt i=0;
   846 	TInt i=0;
   852 	TInt logserverid=aSmsMessage.LogServerId();
   847 	TInt logserverid=aSmsMessage.LogServerId();
   853 	if (logserverid!=KLogNullId)
   848 	if (logserverid!=KLogNullId)
   854 		{
   849 		{
   855 		for (i=0; i<count; i++)
   850 		for (i=0; i<count; i++)
   873                     break;
   868                     break;
   874                 }
   869                 }
   875             }
   870             }
   876 	if(i>=count)
   871 	if(i>=count)
   877 		{
   872 		{
   878 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDREFERENCEL_2, "WARNING! KSmspPanicEntryWithLogServerIdNotFound [i=%d, count=%d]", i, count);
   873 		LOGSMSPROT3("WARNING! KSmspPanicEntryWithLogServerIdNotFound [i=%d, count=%d]", i, count);
   879 		return EFalse;
   874 		return EFalse;
   880 		}
   875 		}
   881 
   876 
   882 	RSmsSegmentationStoreRefStatusArray refStatusArray;
   877 	RSmsSegmentationStoreRefStatusArray refStatusArray;
   883 	CleanupClosePushL(refStatusArray);
   878 	CleanupClosePushL(refStatusArray);
   925  *  @param aReference  The PDU reference.
   920  *  @param aReference  The PDU reference.
   926  */
   921  */
   927 TBool CSmsSegmentationStore::AddReferenceStatusPairL(const CSmsMessage& aSmsMessage,TInt aReference, TUint aSegmentSequenceNumber)
   922 TBool CSmsSegmentationStore::AddReferenceStatusPairL(const CSmsMessage& aSmsMessage,TInt aReference, TUint aSegmentSequenceNumber)
   928  	{
   923  	{
   929 	const TInt count=Entries().Count();
   924 	const TInt count=Entries().Count();
   930 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDREFERENCESTATUSPAIRL_1, "CSmsSegmentationStore::AddReferenceStatusPairL [count=%d, ref=%d]", count, aReference);
   925 	LOGSMSPROT3("CSmsSegmentationStore::AddReferenceStatusPairL [count=%d, ref=%d]", count, aReference);
   931 	TInt i=0;
   926 	TInt i=0;
   932 	TInt logserverid=aSmsMessage.LogServerId();
   927 	TInt logserverid=aSmsMessage.LogServerId();
   933 	if (logserverid!=KLogNullId)
   928 	if (logserverid!=KLogNullId)
   934 		{
   929 		{
   935 		for (i=0; i<count; i++)
   930 		for (i=0; i<count; i++)
   953 				break;
   948 				break;
   954 			}
   949 			}
   955 		}
   950 		}
   956 	if(i>=count)
   951 	if(i>=count)
   957 		{
   952 		{
   958 		OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDREFERENCESTATUSPAIRL_2, "WARNING! KSmspPanicEntryWithLogServerIdNotFound [i=%d, count=%d]", i, count);
   953 		LOGSMSPROT3("WARNING! KSmspPanicEntryWithLogServerIdNotFound [i=%d, count=%d]", i, count);
   959 		return EFalse;
   954 		return EFalse;
   960 		}
   955 		}
   961 
   956 
   962 	RSmsSegmentationStoreRefStatusArray refStatusArray;
   957 	RSmsSegmentationStoreRefStatusArray refStatusArray;
   963 	CleanupClosePushL(refStatusArray);
   958 	CleanupClosePushL(refStatusArray);
  1031 	} // CSmsSegmentationStore::AddReferenceStatusPairL
  1026 	} // CSmsSegmentationStore::AddReferenceStatusPairL
  1032 
  1027 
  1033 
  1028 
  1034 TBool CSmsSegmentationStore::AddStatusReportL(TInt& aIndex,TBool& aComplete,const CSmsMessage& aStatusReport)
  1029 TBool CSmsSegmentationStore::AddStatusReportL(TInt& aIndex,TBool& aComplete,const CSmsMessage& aStatusReport)
  1035 	{
  1030 	{
  1036 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_1, "CSmsSegmentationStore::AddStatusReportL");
  1031 	LOGSMSPROT1("CSmsSegmentationStore::AddStatusReportL");
  1037 
  1032 
  1038 	__ASSERT_DEBUG(aStatusReport.Type()==CSmsPDU::ESmsStatusReport,SmspPanic(KSmspPanicNotStatusReport));
  1033 	__ASSERT_DEBUG(aStatusReport.Type()==CSmsPDU::ESmsStatusReport,SmspPanic(KSmspPanicNotStatusReport));
  1039 
  1034 
  1040 	const CSmsStatusReport& statusreport=(CSmsStatusReport&) aStatusReport.SmsPDU();
  1035 	const CSmsStatusReport& statusreport=(CSmsStatusReport&) aStatusReport.SmsPDU();
  1041 	const TInt reference=statusreport.MessageReference();
  1036 	const TInt reference=statusreport.MessageReference();
  1043 	const TInt isPerm = IsPermanentStatus(status);
  1038 	const TInt isPerm = IsPermanentStatus(status);
  1044 	const TSmsFirstOctet::TSmsStatusReportQualifier qualifier=statusreport.StatusReportQualifier();
  1039 	const TSmsFirstOctet::TSmsStatusReportQualifier qualifier=statusreport.StatusReportQualifier();
  1045 	TBool found=EFalse;
  1040 	TBool found=EFalse;
  1046 	aComplete=EFalse;
  1041 	aComplete=EFalse;
  1047 
  1042 
  1048 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_2, "CSmsSegmentationStore::AddStatusReportL [ref=%d status=%d IsPerm=%d]", reference, status, isPerm);
  1043 	LOGSMSPROT4("CSmsSegmentationStore::AddStatusReportL [ref=%d status=%d IsPerm=%d]", reference, status, isPerm);
  1049 
  1044 
  1050 	if(!isPerm)
  1045 	if(!isPerm)
  1051 		{
  1046 		{
  1052 		return EFalse;
  1047 		return EFalse;
  1053 		}
  1048 		}
  1086 
  1081 
  1087 		TBool sameTelNumbers = entry.Description2().Right(telLen) == parsedaddress.iTelNumber.Right(telLen);
  1082 		TBool sameTelNumbers = entry.Description2().Right(telLen) == parsedaddress.iTelNumber.Right(telLen);
  1088 		
  1083 		
  1089 		if (sameTelNumbers)
  1084 		if (sameTelNumbers)
  1090 			{
  1085 			{
  1091 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_3, "CSmsSegmentationStore::AddStatusReportL telNumber from submit report matches that from SMS message");
  1086 			LOGSMSPROT1("CSmsSegmentationStore::AddStatusReportL telNumber from submit report matches that from SMS message");
  1092 			}
  1087 			}
  1093 		else
  1088 		else
  1094 			{
  1089 			{
  1095 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_4, "CSmsSegmentationStore::AddStatusReportL telNumber from submit report does NOT match that from SMS message");
  1090 			LOGSMSPROT1("CSmsSegmentationStore::AddStatusReportL telNumber from submit report does NOT match that from SMS message");
  1096 			}
  1091 			}
  1097 
  1092 
  1098 		if (sameTelNumbers &&
  1093 		if (sameTelNumbers &&
  1099 		  (((qualifier==TSmsFirstOctet::ESmsStatusReportResultOfCommand) && (type==CSmsPDU::ESmsCommand)) ||
  1094 		  (((qualifier==TSmsFirstOctet::ESmsStatusReportResultOfCommand) && (type==CSmsPDU::ESmsCommand)) ||
  1100 		   ((qualifier==TSmsFirstOctet::ESmsStatusReportResultOfSubmit) &&  (type==CSmsPDU::ESmsSubmit))) &&
  1095 		   ((qualifier==TSmsFirstOctet::ESmsStatusReportResultOfSubmit) &&  (type==CSmsPDU::ESmsSubmit))) &&
  1117 						{
  1112 						{
  1118 						found = ETrue;
  1113 						found = ETrue;
  1119 						}
  1114 						}
  1120 					else
  1115 					else
  1121 						{
  1116 						{
  1122 						OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_5, "CSmsSegmentationStore::AddStatusReportL WARNING: Status already perm [status=%d refStatusPos=%d count=%d]", refStatusArray[refStatusPos].Status(), refStatusPos, refStatusArrayCount);
  1117 						LOGSMSPROT4("CSmsSegmentationStore::AddStatusReportL WARNING: Status already perm [status=%d refStatusPos=%d count=%d]", refStatusArray[refStatusPos].Status(), refStatusPos, refStatusArrayCount);
  1123 						refStatusPos++;
  1118 						refStatusPos++;
  1124 						}
  1119 						}
  1125 					}
  1120 					}
  1126 
  1121 
  1127 				if (found)
  1122 				if (found)
  1128 					{
  1123 					{
  1129 					OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_6, "CSmsSegmentationStore::AddStatusReportL Found [refStatusPos=%d]", refStatusPos);
  1124 					LOGSMSPROT2("CSmsSegmentationStore::AddStatusReportL Found [refStatusPos=%d]", refStatusPos);
  1130 					refStatusArray[refStatusPos].SetStatus(status);
  1125 					refStatusArray[refStatusPos].SetStatus(status);
  1131 					TStreamId streamid=entry.DataStreamId();
  1126 					TStreamId streamid=entry.DataStreamId();
  1132 					ExternalizeEntryL(streamid,smsaddr,*smsmessage, refStatusArray);
  1127 					ExternalizeEntryL(streamid,smsaddr,*smsmessage, refStatusArray);
  1133 					PopulateEntry(entry,*smsmessage, refStatusArray);
  1128 					PopulateEntry(entry,*smsmessage, refStatusArray);
  1134 					ChangeEntryL(aIndex,entry);
  1129 					ChangeEntryL(aIndex,entry);
  1135 					aComplete=StatusArrayComplete(refStatusArray, entry);
  1130 					aComplete=StatusArrayComplete(refStatusArray, entry);
  1136 				    OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_7, "CSmsSegmentationStore::AddStatusReportL StatusArrayComplete %d", aComplete);
  1131 				    LOGSMSPROT2("CSmsSegmentationStore::AddStatusReportL StatusArrayComplete %d", aComplete);
  1137 					}
  1132 					}
  1138 				}
  1133 				}
  1139 			}
  1134 			}
  1140 		}
  1135 		}
  1141 
  1136 
  1191 				TStreamId streamid=entry.DataStreamId();
  1186 				TStreamId streamid=entry.DataStreamId();
  1192 				ExternalizeEntryL(streamid,smsaddr,*smsmessage, refStatusArray2);
  1187 				ExternalizeEntryL(streamid,smsaddr,*smsmessage, refStatusArray2);
  1193 				PopulateEntry(entry,/*smsaddr,*/*smsmessage, refStatusArray2);
  1188 				PopulateEntry(entry,/*smsaddr,*/*smsmessage, refStatusArray2);
  1194 				ChangeEntryL(aIndex,entry);
  1189 				ChangeEntryL(aIndex,entry);
  1195 				aComplete=StatusArrayComplete(refStatusArray2, entry);
  1190 				aComplete=StatusArrayComplete(refStatusArray2, entry);
  1196 			    OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_8, "CSmsSegmentationStore::StatusArrayComplete [aStatus=%d, ret=%d]", status, aComplete);
  1191 			    LOGSMSPROT3("CSmsSegmentationStore::StatusArrayComplete [aStatus=%d, ret=%d]", status, aComplete);
  1197 				break;
  1192 				break;
  1198 				}
  1193 				}
  1199 			}
  1194 			}
  1200 
  1195 
  1201 		CleanupStack::PopAndDestroy(&refStatusArray2);
  1196 		CleanupStack::PopAndDestroy(&refStatusArray2);
  1202 		}
  1197 		}
  1203 
  1198 
  1204 	CommitTransactionL();
  1199 	CommitTransactionL();
  1205 	CleanupStack::PopAndDestroy(2); // smsmessage, refStatusArray
  1200 	CleanupStack::PopAndDestroy(2); // smsmessage, refStatusArray
  1206 
  1201 
  1207 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_ADDSTATUSREPORTL_9, "CSmsSegmentationStore::AddStatusReportL Exit [found=%d]", found);
  1202 	LOGSMSPROT2("CSmsSegmentationStore::AddStatusReportL Exit [found=%d]", found);
  1208 	return found;
  1203 	return found;
  1209 	} // CSmsSegmentationStore::AddStatusReportL
  1204 	} // CSmsSegmentationStore::AddStatusReportL
  1210 
  1205 
  1211 
  1206 
  1212 void CSmsSegmentationStore::GetMessageL(TInt aIndex,TSmsAddr& aSmsAddr,CSmsMessage& aSmsMessage, RSmsSegmentationStoreRefStatusArray& aRefStatusArray)
  1207 void CSmsSegmentationStore::GetMessageL(TInt aIndex,TSmsAddr& aSmsAddr,CSmsMessage& aSmsMessage, RSmsSegmentationStoreRefStatusArray& aRefStatusArray)
  1213 	{
  1208 	{
  1214 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_GETMESSAGEL_1, "CSmsSegmentationStore::GetMessageL [aIndex=%d]", aIndex);
  1209 	LOGSMSPROT2("CSmsSegmentationStore::GetMessageL [aIndex=%d]", aIndex);
  1215 
  1210 
  1216 	InternalizeEntryL(Entries()[aIndex].DataStreamId(),aSmsAddr,aSmsMessage, aRefStatusArray);
  1211 	InternalizeEntryL(Entries()[aIndex].DataStreamId(),aSmsAddr,aSmsMessage, aRefStatusArray);
  1217 	} // CSmsSegmentationStore::GetMessageL
  1212 	} // CSmsSegmentationStore::GetMessageL
  1218 
  1213 
  1219 
  1214 
  1223  *  @note You have to call CSARStore::OpenFileLC() before calling this function
  1218  *  @note You have to call CSARStore::OpenFileLC() before calling this function
  1224  *  and CSARStore::CloseFile() after.
  1219  *  and CSARStore::CloseFile() after.
  1225  */
  1220  */
  1226 void CSmsSegmentationStore::InternalizeConcatenationReferencesL(const TStreamId& aStreamId,TInt& aReference8bit,TInt& aReference16bit)
  1221 void CSmsSegmentationStore::InternalizeConcatenationReferencesL(const TStreamId& aStreamId,TInt& aReference8bit,TInt& aReference16bit)
  1227 	{
  1222 	{
  1228 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_INTERNALIZECONCATENATIONREFERENCESL_1, "CSmsSegmentationStore::InternalizeConcatenationReferencesL Start");
  1223 	LOGSMSPROT1("CSmsSegmentationStore::InternalizeConcatenationReferencesL Start");
  1229 	RStoreReadStream readstream;
  1224 	RStoreReadStream readstream;
  1230 	readstream.OpenLC(FileStore(),aStreamId);
  1225 	readstream.OpenLC(FileStore(),aStreamId);
  1231 	aReference8bit=readstream.ReadInt32L();
  1226 	aReference8bit=readstream.ReadInt32L();
  1232 	aReference16bit=readstream.ReadInt32L();
  1227 	aReference16bit=readstream.ReadInt32L();
  1233 	CleanupStack::PopAndDestroy();
  1228 	CleanupStack::PopAndDestroy();
  1234 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_INTERNALIZECONCATENATIONREFERENCESL_2, "CSmsSegmentationStore::InternalizeConcatenationReferencesL End");
  1229 	LOGSMSPROT1("CSmsSegmentationStore::InternalizeConcatenationReferencesL End");
  1235 	} // CSmsSegmentationStore::InternalizeConcatenationReferencesL
  1230 	} // CSmsSegmentationStore::InternalizeConcatenationReferencesL
  1236 
  1231 
  1237 
  1232 
  1238 /**
  1233 /**
  1239  *  externalize the concat refs from the permanent file store to internal memory
  1234  *  externalize the concat refs from the permanent file store to internal memory
  1241  *  @note You have to call CSARStore::OpenFileLC() before calling this function
  1236  *  @note You have to call CSARStore::OpenFileLC() before calling this function
  1242  *  and CSARStore::CloseFile() after.
  1237  *  and CSARStore::CloseFile() after.
  1243  */
  1238  */
  1244 void CSmsSegmentationStore::ExternalizeConcatenationReferencesL(TStreamId& aStreamId,TInt aReference8bit,TInt aReference16bit)
  1239 void CSmsSegmentationStore::ExternalizeConcatenationReferencesL(TStreamId& aStreamId,TInt aReference8bit,TInt aReference16bit)
  1245 	{
  1240 	{
  1246 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_EXTERNALIZECONCATENATIONREFERENCESL_1, "CSmsSegmentationStore::ExternalizeConcatenationReferencesL Start");
  1241 	LOGSMSPROT1("CSmsSegmentationStore::ExternalizeConcatenationReferencesL Start");
  1247 	RStoreWriteStream writestream;
  1242 	RStoreWriteStream writestream;
  1248 	if (aStreamId==KNullStreamId)
  1243 	if (aStreamId==KNullStreamId)
  1249 		aStreamId=writestream.CreateLC(FileStore());
  1244 		aStreamId=writestream.CreateLC(FileStore());
  1250 	else
  1245 	else
  1251 		writestream.ReplaceLC(FileStore(),aStreamId);
  1246 		writestream.ReplaceLC(FileStore(),aStreamId);
  1252 	writestream.WriteInt32L(aReference8bit);
  1247 	writestream.WriteInt32L(aReference8bit);
  1253 	writestream.WriteInt32L(aReference16bit);
  1248 	writestream.WriteInt32L(aReference16bit);
  1254 	writestream.CommitL();
  1249 	writestream.CommitL();
  1255 	CleanupStack::PopAndDestroy();
  1250 	CleanupStack::PopAndDestroy();
  1256 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_EXTERNALIZECONCATENATIONREFERENCESL_2, "CSmsSegmentationStore::ExternalizeConcatenationReferencesL End");
  1251 	LOGSMSPROT1("CSmsSegmentationStore::ExternalizeConcatenationReferencesL End");
  1257 	} // CSmsSegmentationStore::ExternalizeConcatenationReferencesL
  1252 	} // CSmsSegmentationStore::ExternalizeConcatenationReferencesL
  1258 
  1253 
  1259 
  1254 
  1260 /**
  1255 /**
  1261  *  internalize all the entries from the permanent file store to internal memory
  1256  *  internalize all the entries from the permanent file store to internal memory
  1263  *  @note You have to call CSARStore::OpenFileLC() before calling this function
  1258  *  @note You have to call CSARStore::OpenFileLC() before calling this function
  1264  *  and CSARStore::CloseFile() after.
  1259  *  and CSARStore::CloseFile() after.
  1265  */
  1260  */
  1266 void CSmsSegmentationStore::InternalizeEntryL(const TStreamId& aStreamId,TSmsAddr& aSmsAddr,CSmsMessage& aSmsMessage, RSmsSegmentationStoreRefStatusArray& aRefStatusArray)
  1261 void CSmsSegmentationStore::InternalizeEntryL(const TStreamId& aStreamId,TSmsAddr& aSmsAddr,CSmsMessage& aSmsMessage, RSmsSegmentationStoreRefStatusArray& aRefStatusArray)
  1267 	{
  1262 	{
  1268 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_INTERNALIZEENTRYL_1, "CSmsSegmentationStore::InternalizeEntryL Start");
  1263 	LOGSMSPROT1("CSmsSegmentationStore::InternalizeEntryL Start");
  1269 
  1264 
  1270 	aRefStatusArray.Reset();
  1265 	aRefStatusArray.Reset();
  1271 
  1266 
  1272 	RStoreReadStream readstream;
  1267 	RStoreReadStream readstream;
  1273 	readstream.OpenLC(FileStore(),aStreamId);
  1268 	readstream.OpenLC(FileStore(),aStreamId);
  1274 	readstream >> aSmsAddr;
  1269 	readstream >> aSmsAddr;
  1275 	readstream >> aSmsMessage;
  1270 	readstream >> aSmsMessage;
  1276 	readstream >> aRefStatusArray;
  1271 	readstream >> aRefStatusArray;
  1277 	CleanupStack::PopAndDestroy(&readstream);
  1272 	CleanupStack::PopAndDestroy(&readstream);
  1278 
  1273 
  1279 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_INTERNALIZEENTRYL_2, "CSmsSegmentationStore::InternalizeEntryL End [count=%d]", aRefStatusArray.Count());
  1274 	LOGSMSPROT2("CSmsSegmentationStore::InternalizeEntryL End [count=%d]", aRefStatusArray.Count());
  1280 	} // CSmsSegmentationStore::InternalizeEntryL
  1275 	} // CSmsSegmentationStore::InternalizeEntryL
  1281 
  1276 
  1282 
  1277 
  1283 /**
  1278 /**
  1284  *  externalizes all the entries from the internal memory to the permanent file store
  1279  *  externalizes all the entries from the internal memory to the permanent file store
  1285  */
  1280  */
  1286 void CSmsSegmentationStore::ExternalizeEntryL(TStreamId& aStreamId,const TSmsAddr& aSmsAddr,const CSmsMessage& aSmsMessage, const RSmsSegmentationStoreRefStatusArray& aRefStatusArray)
  1281 void CSmsSegmentationStore::ExternalizeEntryL(TStreamId& aStreamId,const TSmsAddr& aSmsAddr,const CSmsMessage& aSmsMessage, const RSmsSegmentationStoreRefStatusArray& aRefStatusArray)
  1287 	{
  1282 	{
  1288 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_EXTERNALIZEENTRYL_1, "CSmsSegmentationStore::ExternalizeEntryL Start");
  1283 	LOGSMSPROT1("CSmsSegmentationStore::ExternalizeEntryL Start");
  1289 
  1284 
  1290 	RStoreWriteStream writestream;
  1285 	RStoreWriteStream writestream;
  1291 
  1286 
  1292 	if (aStreamId==KNullStreamId)
  1287 	if (aStreamId==KNullStreamId)
  1293 		aStreamId=writestream.CreateLC(FileStore());
  1288 		aStreamId=writestream.CreateLC(FileStore());
  1298 	writestream << aSmsMessage;
  1293 	writestream << aSmsMessage;
  1299 	writestream << aRefStatusArray;
  1294 	writestream << aRefStatusArray;
  1300 	writestream.CommitL();
  1295 	writestream.CommitL();
  1301 	CleanupStack::PopAndDestroy(&writestream);
  1296 	CleanupStack::PopAndDestroy(&writestream);
  1302 
  1297 
  1303 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_EXTERNALIZEENTRYL_2, "CSmsSegmentationStore::ExternalizeEntryL End [count=%d]", aRefStatusArray.Count());
  1298 	LOGSMSPROT2("CSmsSegmentationStore::ExternalizeEntryL End [count=%d]", aRefStatusArray.Count());
  1304 	} // CSmsSegmentationStore::ExternalizeEntryL
  1299 	} // CSmsSegmentationStore::ExternalizeEntryL
  1305 
  1300 
  1306 
  1301 
  1307 /**
  1302 /**
  1308  *  Populates an SMS message into SAR store entry
  1303  *  Populates an SMS message into SAR store entry
  1316  */
  1311  */
  1317 void CSmsSegmentationStore::PopulateEntry(TSmsSegmentationEntry& aEntry,
  1312 void CSmsSegmentationStore::PopulateEntry(TSmsSegmentationEntry& aEntry,
  1318 					  const CSmsMessage& aSmsMessage,
  1313 					  const CSmsMessage& aSmsMessage,
  1319 					  const RSmsSegmentationStoreRefStatusArray& aRefStatusArray)
  1314 					  const RSmsSegmentationStoreRefStatusArray& aRefStatusArray)
  1320 	{
  1315 	{
  1321 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_POPULATEENTRY_1, "CSmsSegmentationStore::PopulateEntry");
  1316 	LOGSMSPROT1("CSmsSegmentationStore::PopulateEntry");
  1322 	TBool statusreportrequest=EFalse;
  1317 	TBool statusreportrequest=EFalse;
  1323 	if (aSmsMessage.Type()==CSmsPDU::ESmsSubmit)
  1318 	if (aSmsMessage.Type()==CSmsPDU::ESmsSubmit)
  1324 		{
  1319 		{
  1325 		aEntry.SetReference(0);
  1320 		aEntry.SetReference(0);
  1326 		aEntry.SetTotal(1);
  1321 		aEntry.SetTotal(1);
  1424 	TInt permanent=0;
  1419 	TInt permanent=0;
  1425 	const TInt count= aRefStatusArray.Count();
  1420 	const TInt count= aRefStatusArray.Count();
  1426 	for (TInt i=0; i<count; i++)
  1421 	for (TInt i=0; i<count; i++)
  1427 		{
  1422 		{
  1428 		const TBool ret = IsPermanentStatus(aRefStatusArray[i].Status());
  1423 		const TBool ret = IsPermanentStatus(aRefStatusArray[i].Status());
  1429 		OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_STATUSARRAYCOMPLETE_1, "CSmsSegmentationStore::IsPermanentStatus [Status: %d, RetVal: %d, count=%d]", aRefStatusArray[i].Status(), ret, count);
  1424 		LOGSMSPROT4("CSmsSegmentationStore::IsPermanentStatus [Status: %d, RetVal: %d, count=%d]", aRefStatusArray[i].Status(), ret, count);
  1430 		if (ret)
  1425 		if (ret)
  1431 			permanent++;
  1426 			permanent++;
  1432 		}
  1427 		}
  1433 	return (permanent==count) && (permanent==aEntry.Total() );
  1428 	return (permanent==count) && (permanent==aEntry.Total() );
  1434 	} // CSmsSegmentationStore::StatusArrayComplete
  1429 	} // CSmsSegmentationStore::StatusArrayComplete
  1438    *  C'tor
  1433    *  C'tor
  1439    */
  1434    */
  1440 CSmsSegmentationStore::CSmsSegmentationStore(RFs& aFs)
  1435 CSmsSegmentationStore::CSmsSegmentationStore(RFs& aFs)
  1441     :CSARStore(aFs)
  1436     :CSARStore(aFs)
  1442     {
  1437     {
  1443     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_CTOR_1, "CSmsSegmentationStore::CSmsSegmentationStore()");
  1438     LOGSMSPROT1("CSmsSegmentationStore::CSmsSegmentationStore()");
  1444 
  1439 
  1445     } // CSmsSegmentationStore::CSmsSegmentationStore
  1440     } // CSmsSegmentationStore::CSmsSegmentationStore
  1446 
  1441 
  1447 
  1442 
  1448 TInt CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::Compare(const TSmsSegmentationStoreRefStatus& aLeft, const TSmsSegmentationStoreRefStatus& aRight)
  1443 TInt CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::Compare(const TSmsSegmentationStoreRefStatus& aLeft, const TSmsSegmentationStoreRefStatus& aRight)
  1449 	{
  1444 	{
  1450 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_TSMSSEGMENTATIONSTOREREFSTATUS_COMPARE_1, "CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::Compare()");
  1445 	LOGSMSPROT1("CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::Compare()");
  1451 
  1446 
  1452 	return aLeft.iReference - aRight.iReference;
  1447 	return aLeft.iReference - aRight.iReference;
  1453 	} // CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::Compare
  1448 	} // CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::Compare
  1454 
  1449 
  1455 
  1450 
  1456 void CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::InternalizeL(RReadStream& aStream)
  1451 void CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::InternalizeL(RReadStream& aStream)
  1457 	{
  1452 	{
  1458 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_TSMSSEGMENTATIONSTOREREFSTATUS_INTERNALIZEL_1, "CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::InternalizeL()");
  1453 	LOGSMSPROT1("CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::InternalizeL()");
  1459 
  1454 
  1460 	iReference = aStream.ReadInt32L();
  1455 	iReference = aStream.ReadInt32L();
  1461 	iStatus = aStream.ReadInt32L();
  1456 	iStatus = aStream.ReadInt32L();
  1462 	} // CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::InternalizeL
  1457 	} // CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::InternalizeL
  1463 
  1458 
  1464 
  1459 
  1465 void CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::ExternalizeL(RWriteStream& aStream) const
  1460 void CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::ExternalizeL(RWriteStream& aStream) const
  1466 	{
  1461 	{
  1467 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_TSMSSEGMENTATIONSTOREREFSTATUS_EXTERNALIZEL_1, "CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::ExternalizeL()");
  1462 	LOGSMSPROT1("CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::ExternalizeL()");
  1468 
  1463 
  1469 	aStream.WriteInt32L(iReference);
  1464 	aStream.WriteInt32L(iReference);
  1470 	aStream.WriteInt32L(iStatus);
  1465 	aStream.WriteInt32L(iStatus);
  1471 	} // CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::ExternalizeL
  1466 	} // CSmsSegmentationStore::TSmsSegmentationStoreRefStatus::ExternalizeL
  1472 
  1467 
  1473 
  1468 
  1474 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InsertL(const TSmsSegmentationStoreRefStatus& aRefStatus)
  1469 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InsertL(const TSmsSegmentationStoreRefStatus& aRefStatus)
  1475 	{
  1470 	{
  1476 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_RSMSSEGMENTATIONSTOREREFSTATUSARRAY_INSERTL_1, "CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InsertL()");
  1471 	LOGSMSPROT1("CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InsertL()");
  1477 
  1472 
  1478 	TLinearOrder<TSmsSegmentationStoreRefStatus> order(TSmsSegmentationStoreRefStatus::Compare);
  1473 	TLinearOrder<TSmsSegmentationStoreRefStatus> order(TSmsSegmentationStoreRefStatus::Compare);
  1479 	User::LeaveIfError(InsertInOrderAllowRepeats(aRefStatus, order));
  1474 	User::LeaveIfError(InsertInOrderAllowRepeats(aRefStatus, order));
  1480 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InsertL
  1475 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InsertL
  1481 
  1476 
  1482 
  1477 
  1483 TInt CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::Find(const TSmsSegmentationStoreRefStatus& aRefStatus) const
  1478 TInt CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::Find(const TSmsSegmentationStoreRefStatus& aRefStatus) const
  1484 	{
  1479 	{
  1485 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_RSMSSEGMENTATIONSTOREREFSTATUSARRAY_FIND_1, "CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::Find()");
  1480 	LOGSMSPROT1("CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::Find()");
  1486 
  1481 
  1487 	TLinearOrder<TSmsSegmentationStoreRefStatus> order(TSmsSegmentationStoreRefStatus::Compare);
  1482 	TLinearOrder<TSmsSegmentationStoreRefStatus> order(TSmsSegmentationStoreRefStatus::Compare);
  1488 	TInt index = FindInOrder(aRefStatus, order);
  1483 	TInt index = FindInOrder(aRefStatus, order);
  1489 	if (index != KErrNotFound)
  1484 	if (index != KErrNotFound)
  1490 		{
  1485 		{
  1500 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::Find
  1495 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::Find
  1501 
  1496 
  1502 
  1497 
  1503 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::CopyL(const RSmsSegmentationStoreRefStatusArray& aOther)
  1498 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::CopyL(const RSmsSegmentationStoreRefStatusArray& aOther)
  1504 	{
  1499 	{
  1505 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_RSMSSEGMENTATIONSTOREREFSTATUSARRAY_COPYL_1, "CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::CopyL()");
  1500 	LOGSMSPROT1("CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::CopyL()");
  1506 
  1501 
  1507 	Reset();
  1502 	Reset();
  1508 
  1503 
  1509 	TInt count = aOther.Count();
  1504 	TInt count = aOther.Count();
  1510 	while (count--)
  1505 	while (count--)
  1514 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::CopyL
  1509 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::CopyL
  1515 
  1510 
  1516 
  1511 
  1517 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ResetAllStatus(TInt aStatus)
  1512 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ResetAllStatus(TInt aStatus)
  1518 	{
  1513 	{
  1519 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_RSMSSEGMENTATIONSTOREREFSTATUSARRAY_RESETALLSTATUS_1, "CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ResetAllStatus()");
  1514 	LOGSMSPROT1("CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ResetAllStatus()");
  1520 
  1515 
  1521 	TInt count = Count();
  1516 	TInt count = Count();
  1522 	while (count--)
  1517 	while (count--)
  1523 		{
  1518 		{
  1524 		(*this)[count].SetStatus(aStatus);
  1519 		(*this)[count].SetStatus(aStatus);
  1526 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ResetAllStatus
  1521 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ResetAllStatus
  1527 
  1522 
  1528 
  1523 
  1529 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InternalizeL(RReadStream& aStream)
  1524 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InternalizeL(RReadStream& aStream)
  1530 	{
  1525 	{
  1531 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_RSMSSEGMENTATIONSTOREREFSTATUSARRAY_INTERNALIZEL_1, "CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InternalizeL()");
  1526 	LOGSMSPROT1("CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InternalizeL()");
  1532 
  1527 
  1533 	TInt count = aStream.ReadInt32L();
  1528 	TInt count = aStream.ReadInt32L();
  1534 	while (count--)
  1529 	while (count--)
  1535 		{
  1530 		{
  1536 		TSmsSegmentationStoreRefStatus refStatus;
  1531 		TSmsSegmentationStoreRefStatus refStatus;
  1540 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InternalizeL
  1535 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::InternalizeL
  1541 
  1536 
  1542 
  1537 
  1543 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ExternalizeL(RWriteStream& aStream) const
  1538 void CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ExternalizeL(RWriteStream& aStream) const
  1544 	{
  1539 	{
  1545 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_RSMSSEGMENTATIONSTOREREFSTATUSARRAYEXTERNALIZEL_1, "CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ExternalizeL()");
  1540 	LOGSMSPROT1("CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ExternalizeL()");
  1546 
  1541 
  1547 	const TInt count = Count();
  1542 	const TInt count = Count();
  1548 	aStream.WriteInt32L(count);
  1543 	aStream.WriteInt32L(count);
  1549 
  1544 
  1550 	for (TInt i = 0; i < count; i++)
  1545 	for (TInt i = 0; i < count; i++)
  1554 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ExternalizeL
  1549 	} // CSmsSegmentationStore::RSmsSegmentationStoreRefStatusArray::ExternalizeL
  1555 
  1550 
  1556 
  1551 
  1557 TBool CSmsSegmentationStore::HasEntryWithLogIdL(TLogId aLogID,TInt& aRefNo,TInt& aSent)
  1552 TBool CSmsSegmentationStore::HasEntryWithLogIdL(TLogId aLogID,TInt& aRefNo,TInt& aSent)
  1558 	{
  1553 	{
  1559 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_HASENTRYWITHLOGIDL_1, "CSmsSegmentationStore::HasEntryWithLogIdL()");
  1554 	LOGSMSPROT1("CSmsSegmentationStore::HasEntryWithLogIdL()");
  1560 
  1555 
  1561 	TInt count=Entries().Count();
  1556 	TInt count=Entries().Count();
  1562 	TBool found=EFalse;
  1557 	TBool found=EFalse;
  1563 	if(aLogID != KLogNullId)
  1558 	if(aLogID != KLogNullId)
  1564 		{
  1559 		{
  1579 					found=ETrue;
  1574 					found=ETrue;
  1580 					}
  1575 					}
  1581 				else
  1576 				else
  1582 					{
  1577 					{
  1583 					DeleteEntryL(i);
  1578 					DeleteEntryL(i);
  1584 					OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_HASENTRYWITHLOGIDL_2, "CSmsSegmentationStore::HasEntryWithLogIdL [Entry: %d LogId %d - deleted]", i, (TInt)aLogID );
  1579 					LOGSMSPROT3("CSmsSegmentationStore::HasEntryWithLogIdL [Entry: %d LogId %d - deleted]", i, aLogID );
  1585 					}
  1580 					}
  1586 				break;
  1581 				break;
  1587 				}
  1582 				}
  1588 			}
  1583 			}
  1589 		CommitTransactionL();
  1584 		CommitTransactionL();
  1595 /**
  1590 /**
  1596  *  Open the sms segmentation store.
  1591  *  Open the sms segmentation store.
  1597  */
  1592  */
  1598 void CSmsSegmentationStore::OpenStoreL()
  1593 void CSmsSegmentationStore::OpenStoreL()
  1599 	{
  1594 	{
  1600 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSMSSEGMENTATIONSTORE_OPENSTOREL_1, "CSmsSegmentationStore::OpenStoreL()");
  1595 	LOGSMSPROT1("CSmsSegmentationStore::OpenStoreL()");
  1601 
  1596 
  1602 	this->OpenL(iFullPathBuf,KSegmentationStoreUid);
  1597 	this->OpenL(iFullPathBuf,KSegmentationStoreUid);
  1603 	} // CSmsSegmentationStore::OpenStoreL
  1598 	} // CSmsSegmentationStore::OpenStoreL