smsprotocols/smsstack/gsmu/src/gsmustor.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 "gsmustorTraces.h"
       
    26 #endif
       
    27 
       
    28 #include <e32svr.h>
    22 #include <e32svr.h>
    29 
    23 
    30 #include "gsmustor.h"
    24 #include "gsmustor.h"
    31 #include "Gsmumain.h"
    25 #include "Gsmumain.h"
    32 
    26 
    37 /**
    31 /**
    38  *  Utility func for cleanup stack - close the filestore and set pointer to NULL
    32  *  Utility func for cleanup stack - close the filestore and set pointer to NULL
    39  */
    33  */
    40 void CSARStoreCloseObject(TAny* aObj)
    34 void CSARStoreCloseObject(TAny* aObj)
    41     {
    35     {
    42     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORECLOSEOBJECT_1, "WARNING! Hey, CSARStoreCloseObject called by Untrapper! [0x%08x]", aObj);
    36     LOGGSMU2("WARNING! Hey, CSARStoreCloseObject called by Untrapper! [0x%08x]", aObj);
    43     ((CSARStore*)aObj)->Revert();
    37     ((CSARStore*)aObj)->Revert();
    44     }
    38     }
    45 
    39 
    46 //
    40 //
    47 // implementation of TSAREntry
    41 // implementation of TSAREntry
   129  *  @param aThirdUid Third UID for the filestore.
   123  *  @param aThirdUid Third UID for the filestore.
   130  *  @capability None
   124  *  @capability None
   131  */
   125  */
   132 EXPORT_C void CSARStore::OpenL(const TDesC& aFullName, const TUid& aThirdUid)
   126 EXPORT_C void CSARStore::OpenL(const TDesC& aFullName, const TUid& aThirdUid)
   133 	{
   127 	{
   134 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_OPENL_1, "CSARStore::OpenL(): '%S'", aFullName);
   128 #ifdef _SMS_LOGGING_ENABLED
       
   129 	TBuf8<80> buf8;
       
   130 	buf8.Copy(aFullName);
       
   131 	LOGGSMU2("CSARStore::OpenL(): '%S'", &buf8);
       
   132 #endif
   135 
   133 
   136 	// sanity check
   134 	// sanity check
   137 	__ASSERT_DEBUG(iFileStore==NULL,Panic(KGsmuPanicSARStoreAlreadyOpen));
   135 	__ASSERT_DEBUG(iFileStore==NULL,Panic(KGsmuPanicSARStoreAlreadyOpen));
   138 	__ASSERT_DEBUG(!iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   136 	__ASSERT_DEBUG(!iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   139 	__ASSERT_DEBUG(iEntryArray.Count()==0,Panic(KGsmuPanicSARStoreEntryArrayNotReset));
   137 	__ASSERT_DEBUG(iEntryArray.Count()==0,Panic(KGsmuPanicSARStoreEntryArrayNotReset));
   145  	// defect fix for EDNJJUN-4WYJGP
   143  	// defect fix for EDNJJUN-4WYJGP
   146  	// Unable to send sms cause sms*.dat is corrupted
   144  	// Unable to send sms cause sms*.dat is corrupted
   147  	TRAPD(ret, InternalizeEntryArrayL());
   145  	TRAPD(ret, InternalizeEntryArrayL());
   148 	if (ret != KErrNone)
   146 	if (ret != KErrNone)
   149 		{
   147 		{
   150 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_OPENL_2, "WARNING: InteralizeEntryArrayL left with %d", ret);
   148 		LOGGSMU2("WARNING: InteralizeEntryArrayL left with %d", ret);
   151 		}
   149 		}
   152 
   150 
   153  	if(ret == KErrCorrupt || ret == KErrEof || ret == KErrNotFound)
   151  	if(ret == KErrCorrupt || ret == KErrEof || ret == KErrNotFound)
   154 	 	{
   152 	 	{
   155  		Close();             //because the file is in use
   153  		Close();             //because the file is in use
   166  *  @capability None
   164  *  @capability None
   167  */
   165  */
   168 EXPORT_C void CSARStore::CommitTransactionL()
   166 EXPORT_C void CSARStore::CommitTransactionL()
   169 // This function does the real work of updating the filestore
   167 // This function does the real work of updating the filestore
   170 	{
   168 	{
   171     OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_COMMITTRANSACTIONL_1, "CSARStore::CommitTransactionL(): this=0x%08X iInTransaction=%d iFileStore=0x%08X",(TUint)this, iInTransaction, (TUint)iFileStore);
   169     LOGGSMU4("CSARStore::CommitTransactionL(): this=0x%08X iInTransaction=%d iFileStore=0x%08X",
       
   170     		 this, iInTransaction, iFileStore);
   172 
   171 
   173 	__ASSERT_DEBUG(iFileStore!=NULL, Panic(KGsmuPanicSARStoreNotOpen));
   172 	__ASSERT_DEBUG(iFileStore!=NULL, Panic(KGsmuPanicSARStoreNotOpen));
   174 	__ASSERT_DEBUG(iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   173 	__ASSERT_DEBUG(iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   175 
   174 
   176 #ifdef OST_TRACE_COMPILER_IN_USE
   175 #ifdef _SMS_LOGGING_ENABLED
   177 	TRAPD(err, DoCommitAndCompactL());
   176 	TRAPD(err, DoCommitAndCompactL());
   178 	if (err != KErrNone)
   177 	if (err != KErrNone)
   179 		{
   178 		{
   180 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_COMMITTRANSACTIONL_2, "WARNING! could not CommitL/CompactL due to %d", err);
   179 		LOGGSMU2("WARNING! could not CommitL/CompactL due to %d", err);
   181 		User::Leave(err);
   180 		User::Leave(err);
   182 		}
   181 		}
   183 #else
   182 #else
   184 	DoCommitAndCompactL();
   183 	DoCommitAndCompactL();
   185 #endif
   184 #endif
   198  *  should be called once when the protocol module is closing down.
   197  *  should be called once when the protocol module is closing down.
   199  *  @capability None
   198  *  @capability None
   200  */
   199  */
   201 EXPORT_C void CSARStore::Close()
   200 EXPORT_C void CSARStore::Close()
   202 	{
   201 	{
   203 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_CLOSE_1, "CSARStore::Close(): '%S'", iFullName);
   202 #ifdef _SMS_LOGGING_ENABLED
       
   203 	TBuf8<80> buf8;
       
   204 	buf8.Copy(iFullName);
       
   205 	LOGGSMU2("CSARStore::Close(): '%S'", &buf8);
       
   206 #endif
   204 
   207 
   205 	__ASSERT_DEBUG(!iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   208 	__ASSERT_DEBUG(!iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   206 
   209 
   207 	delete iFileStore;
   210 	delete iFileStore;
   208 	iFileStore=NULL;
   211 	iFileStore=NULL;
   258 // after the reboot of the device the information in the stores could be lost
   261 // after the reboot of the device the information in the stores could be lost
   259 // due to purging or compacting - a single pdu always gets lost due to not
   262 // due to purging or compacting - a single pdu always gets lost due to not
   260 // storing it in the reassembly store.
   263 // storing it in the reassembly store.
   261 //
   264 //
   262 	{
   265 	{
   263 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_PURGEL_1, "CSARStore::PurgeL(): aTimeIntervalMinutes=%d, aPurgeIncompleteOnly=%d",aTimeIntervalMinutes.Int(), aPurgeIncompleteOnly);
   266 	LOGGSMU3("CSARStore::PurgeL(): aTimeIntervalMinutes=%d, aPurgeIncompleteOnly=%d",
       
   267 			 aTimeIntervalMinutes.Int(), aPurgeIncompleteOnly);
   264 
   268 
   265 	// TODO - flag
   269 	// TODO - flag
   266 	// we could also save the call of the method from the consruction of the smsprot
   270 	// we could also save the call of the method from the consruction of the smsprot
   267 	if( aPurgeIncompleteOnly )
   271 	if( aPurgeIncompleteOnly )
   268 		return;
   272 		return;
   269 
   273 
   270 	TInt count=iEntryArray.Count();
   274 	TInt count=iEntryArray.Count();
   271 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_PURGEL_2, "CSARStore::PurgeL(): count=%d", count);
   275 	LOGGSMU2("CSARStore::PurgeL(): count=%d", count);
   272 
   276 
   273 	TTime time;
   277 	TTime time;
   274 	time.UniversalTime();
   278 	time.UniversalTime();
   275 
   279 
   276 	// we open the file outside the loop
   280 	// we open the file outside the loop
   307  *  to purge incomplete messages only.
   311  *  to purge incomplete messages only.
   308  *  @capability None
   312  *  @capability None
   309  */
   313  */
   310 EXPORT_C void CSARStore::PurgeL(TInt aKSegmentationLifetimeMultiplier,TBool aPurgeIncompleteOnly)
   314 EXPORT_C void CSARStore::PurgeL(TInt aKSegmentationLifetimeMultiplier,TBool aPurgeIncompleteOnly)
   311 	{
   315 	{
   312 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_PURGEL1_1, "CSARStore::PurgeL(): aKSegmentationLifetimeMultiplier=%d, aPurgeIncompleteOnly=%d",aKSegmentationLifetimeMultiplier, aPurgeIncompleteOnly);
   316 	LOGGSMU3("CSARStore::PurgeL(): aKSegmentationLifetimeMultiplier=%d, aPurgeIncompleteOnly=%d",
       
   317 			 aKSegmentationLifetimeMultiplier, aPurgeIncompleteOnly);
   313 
   318 
   314 	TInt count=Entries().Count();
   319 	TInt count=Entries().Count();
   315 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_PURGEL1_2, "CSARStore::PurgeL(): count=%d", count);
   320 	LOGGSMU2("CSARStore::PurgeL(): count=%d", count);
   316 	TTime time;
   321 	TTime time;
   317 	time.UniversalTime();
   322 	time.UniversalTime();
   318 
   323 
   319 	// we open the file outside the loop
   324 	// we open the file outside the loop
   320 	// to save some CPU
   325 	// to save some CPU
   368 			}
   373 			}
   369 		}
   374 		}
   370 	    
   375 	    
   371 	ExternalizeEntryArrayL();
   376 	ExternalizeEntryArrayL();
   372 	CommitTransactionL();
   377 	CommitTransactionL();
   373 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_PURGEL1_3, "CSmsSegmentationStore::PurgeL End");
   378 	LOGGSMU1("CSmsSegmentationStore::PurgeL End");
   374 	} // CSARStore::PurgeL
   379 	} // CSARStore::PurgeL
   375 
   380 
   376 
   381 
   377 /**
   382 /**
   378  *  Deletes an entry from the entry array, and externalizes it.
   383  *  Deletes an entry from the entry array, and externalizes it.
   382  *  @param aIndex Entry in the SAR store to delete
   387  *  @param aIndex Entry in the SAR store to delete
   383  *  @capability None
   388  *  @capability None
   384  */
   389  */
   385 EXPORT_C void CSARStore::DeleteEntryL(TInt aIndex)
   390 EXPORT_C void CSARStore::DeleteEntryL(TInt aIndex)
   386 	{
   391 	{
   387 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_DELETEENTRYL_1, "CSARStore::DeleteEntryL(): aIndex=%d", aIndex);
   392 	LOGGSMU2("CSARStore::DeleteEntryL(): aIndex=%d", aIndex);
   388 
   393 
   389 	DoDeleteEntryL(aIndex);
   394 	DoDeleteEntryL(aIndex);
   390 	ExternalizeEntryArrayL();
   395 	ExternalizeEntryArrayL();
   391 	} // CSARStore::DeleteEntryL
   396 	} // CSARStore::DeleteEntryL
   392 
   397 
   420  *  @return The filestore
   425  *  @return The filestore
   421  *  @capability None
   426  *  @capability None
   422  */
   427  */
   423 EXPORT_C CFileStore& CSARStore::FileStore()
   428 EXPORT_C CFileStore& CSARStore::FileStore()
   424 	{
   429 	{
   425 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_FILESTORE_1, "CSARStore::FileStore()");
   430 	LOGGSMU1("CSARStore::FileStore()");
   426 
   431 
   427 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   432 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   428 	return *iFileStore;
   433 	return *iFileStore;
   429 	} // CSARStore::FileStore
   434 	} // CSARStore::FileStore
   430 
   435 
   437  */
   442  */
   438 EXPORT_C const CFileStore& CSARStore::FileStore() const
   443 EXPORT_C const CFileStore& CSARStore::FileStore() const
   439     {
   444     {
   440     // Ignore in code coverage - not used in SMS stack.
   445     // Ignore in code coverage - not used in SMS stack.
   441     BULLSEYE_OFF
   446     BULLSEYE_OFF
   442     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_FILESTORE1_1, "CSARStore::FileStore()");
   447     LOGGSMU1("CSARStore::FileStore()");
   443     __ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   448     __ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   444     return *iFileStore;
   449     return *iFileStore;
   445     BULLSEYE_RESTORE
   450     BULLSEYE_RESTORE
   446     }
   451     }
   447 
   452 
   456  *  @param aEntry SAR entry to add
   461  *  @param aEntry SAR entry to add
   457  *  @capability None
   462  *  @capability None
   458  */
   463  */
   459 EXPORT_C void CSARStore::AddEntryL(const TSAREntry& aEntry)
   464 EXPORT_C void CSARStore::AddEntryL(const TSAREntry& aEntry)
   460 	{
   465 	{
   461 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_ADDENTRYL_1, "CSARStore::AddEntryL()");
   466 	LOGGSMU1("CSARStore::AddEntryL()");
   462 
   467 
   463 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   468 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   464 	__ASSERT_DEBUG(aEntry.DataStreamId()!=KNullStreamId,Panic(KGsmuPanicSAREntryDataStreamIdNotSet));
   469 	__ASSERT_DEBUG(aEntry.DataStreamId()!=KNullStreamId,Panic(KGsmuPanicSAREntryDataStreamIdNotSet));
   465 	iEntryArray.AppendL(aEntry);
   470 	iEntryArray.AppendL(aEntry);
   466 	iEntryArray[iEntryArray.Count()-1].SetIsAdded(ETrue);
   471 	iEntryArray[iEntryArray.Count()-1].SetIsAdded(ETrue);
   478  *  @param aNewEntry The new SAR store entry
   483  *  @param aNewEntry The new SAR store entry
   479  *  @capability None
   484  *  @capability None
   480  */
   485  */
   481 EXPORT_C void CSARStore::ChangeEntryL(TInt aIndex,const TSAREntry& aNewEntry)
   486 EXPORT_C void CSARStore::ChangeEntryL(TInt aIndex,const TSAREntry& aNewEntry)
   482 	{
   487 	{
   483 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_CHANGEENTRYL_1, "CSARStore::ChangeEntryL(): aIndex=%d", aIndex);
   488 	LOGGSMU2("CSARStore::ChangeEntryL(): aIndex=%d", aIndex);
   484 
   489 
   485 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   490 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   486 	__ASSERT_DEBUG(iEntryArray[aIndex].DataStreamId()==aNewEntry.DataStreamId(),Panic(KGsmuPanicSAREntryDataStreamIdChanged));
   491 	__ASSERT_DEBUG(iEntryArray[aIndex].DataStreamId()==aNewEntry.DataStreamId(),Panic(KGsmuPanicSAREntryDataStreamIdChanged));
   487 
   492 
   488 	iEntryArray[aIndex].SetIsDeleted(ETrue);
   493 	iEntryArray[aIndex].SetIsDeleted(ETrue);
   499  *  @return Extra stream ID
   504  *  @return Extra stream ID
   500  *  @capability None
   505  *  @capability None
   501  */
   506  */
   502 EXPORT_C TStreamId CSARStore::ExtraStreamId() const
   507 EXPORT_C TStreamId CSARStore::ExtraStreamId() const
   503 	{
   508 	{
   504 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_EXTRASTREAMID_1, "CSARStore::ExtraStreamId");
   509 	LOGGSMU1("CSARStore::ExtraStreamId");
   505 	return iExtraStreamId;
   510 	return iExtraStreamId;
   506 	} // CSARStore::ExtraStreamId
   511 	} // CSARStore::ExtraStreamId
   507 
   512 
   508 
   513 
   509 /**
   514 /**
   515  *  @param aExtraStreamId Extra stream ID
   520  *  @param aExtraStreamId Extra stream ID
   516  *  @capability None
   521  *  @capability None
   517  */
   522  */
   518 EXPORT_C void CSARStore::SetExtraStreamIdL(const TStreamId& aExtraStreamId)
   523 EXPORT_C void CSARStore::SetExtraStreamIdL(const TStreamId& aExtraStreamId)
   519 	{
   524 	{
   520 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_SETEXTRASTREAMIDL_1, "CSARStore::SetExtraStreamIdL(): id=%d", aExtraStreamId.Value());
   525 	LOGGSMU2("CSARStore::SetExtraStreamIdL(): id=%d", aExtraStreamId.Value());
   521 
   526 
   522 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   527 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   523 	TStreamId streamid=iExtraStreamId;
   528 	TStreamId streamid=iExtraStreamId;
   524 	iExtraStreamId=aExtraStreamId;
   529 	iExtraStreamId=aExtraStreamId;
   525 	TRAPD(ret, ExternalizeEntryArrayL());
   530 	TRAPD(ret, ExternalizeEntryArrayL());
   526 	if (ret!=KErrNone)
   531 	if (ret!=KErrNone)
   527 		{
   532 		{
   528 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_SETEXTRASTREAMIDL_2, "WARNING! CSARStore::DoExternalizeEntryArrayL left with %d", ret);
   533 		LOGGSMU2("WARNING! CSARStore::DoExternalizeEntryArrayL left with %d", ret);
   529 		iExtraStreamId=streamid;	//  Roll back
   534 		iExtraStreamId=streamid;	//  Roll back
   530 		User::Leave(ret);			//  re-leave to allow caller to also roll back
   535 		User::Leave(ret);			//  re-leave to allow caller to also roll back
   531 		}
   536 		}
   532 	} // CSARStore::SetExtraStreamIdL
   537 	} // CSARStore::SetExtraStreamIdL
   533 
   538 
   541  *  This function opens and closes the file automatically.
   546  *  This function opens and closes the file automatically.
   542  *  @capability None
   547  *  @capability None
   543  */
   548  */
   544 EXPORT_C void CSARStore::CompactL()
   549 EXPORT_C void CSARStore::CompactL()
   545 	{
   550 	{
   546     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_COMPACTL_1, "CSARStore::CompactL Start");
   551     LOGGSMU1("CSARStore::CompactL Start");
   547 	__ASSERT_DEBUG(iFileStore!=NULL, Panic(KGsmuPanicSARStoreNotOpen));
   552 	__ASSERT_DEBUG(iFileStore!=NULL, Panic(KGsmuPanicSARStoreNotOpen));
   548 	__ASSERT_DEBUG(iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   553 	__ASSERT_DEBUG(iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   549 
   554 
   550 	TInt space = iFileStore->CompactL();
   555 	TInt space = iFileStore->CompactL();
   551 	iFileStore->CommitL();
   556 	iFileStore->CommitL();
   552 
   557 
   553     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_COMPACTL_2, "CSARStore::CompactL End [space=%d]", space);
   558     LOGGSMU2("CSARStore::CompactL End [space=%d]", space);
   554 	(void)space;
   559 	(void)space;
   555 	} // CSARStore::CompactL
   560 	} // CSARStore::CompactL
   556 
   561 
   557 
   562 
   558 /**
   563 /**
   562  *  invalid.
   567  *  invalid.
   563  *  @capability None
   568  *  @capability None
   564  */
   569  */
   565 EXPORT_C void CSARStore::BeginTransactionLC()
   570 EXPORT_C void CSARStore::BeginTransactionLC()
   566 	{
   571 	{
   567     OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_BEGINTRANSACTIONLC_1, "CSARStore::BeginTransactionLC [this=0x%08X iInTransaction=%d iFileStore=0x%08X]", (TUint)this, iInTransaction, (TUint)iFileStore);
   572     LOGGSMU4("CSARStore::BeginTransactionLC [this=0x%08X iInTransaction=%d iFileStore=0x%08X]", this, iInTransaction, iFileStore);
   568 
   573 
   569 	if (iFileStore == NULL || iInTransaction)
   574 	if (iFileStore == NULL || iInTransaction)
   570 		{
   575 		{
   571 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_BEGINTRANSACTIONLC_2, "WARNING CSARStore::BeginTransactionLC leaving with KErrAccessDenied");
   576 	    LOGGSMU1("WARNING CSARStore::BeginTransactionLC leaving with KErrAccessDenied");
   572 		User::Leave(KErrAccessDenied);
   577 		User::Leave(KErrAccessDenied);
   573 		}
   578 		}
   574 
   579 
   575 	TCleanupItem sarClose(CSARStoreCloseObject, this);
   580 	TCleanupItem sarClose(CSARStoreCloseObject, this);
   576 	CleanupStack::PushL(sarClose);
   581 	CleanupStack::PushL(sarClose);
   577 	iInTransaction = ETrue;
   582 	iInTransaction = ETrue;
   578 	} // CSARStore::BeginTransactionLC
   583 	} // CSARStore::BeginTransactionLC
   579 
   584 
   580 void CSARStore::Revert()
   585 void CSARStore::Revert()
   581 	{
   586 	{
   582     OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_REVERT_1, "CSARStore::Revert(): this=0x%08X, iInTransaction=%d", (TUint)this, iInTransaction);
   587     LOGGSMU3("CSARStore::Revert(): this=0x%08X, iInTransaction=%d",
       
   588     		 this, iInTransaction);
   583 
   589 
   584 	__ASSERT_DEBUG(iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   590 	__ASSERT_DEBUG(iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   585 
   591 
   586 	iFileStore->Revert();
   592 	iFileStore->Revert();
   587 	iInTransaction = EFalse;
   593 	iInTransaction = EFalse;
   596  *  the file is not there, it creates a new one.
   602  *  the file is not there, it creates a new one.
   597  *  @capability None
   603  *  @capability None
   598  */
   604  */
   599 EXPORT_C void CSARStore::DoOpenL()
   605 EXPORT_C void CSARStore::DoOpenL()
   600 	{
   606 	{
   601 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_DOOPENL_1, "CSARStore::DoOpenL(): '%S' this=0x%08X", iFullName, (TUint)this);
   607 #ifdef _SMS_LOGGING_ENABLED
   602 
   608 	TBuf8<80> buf8;
       
   609 	buf8.Copy(iFullName);
       
   610 	LOGGSMU3("CSARStore::DoOpenL(): '%S' this=0x%08X", &buf8, this);
       
   611 #endif
   603 
   612 
   604 	TUidType uidtype(KPermanentFileStoreLayoutUid,KSARStoreUid,iThirdUid);
   613 	TUidType uidtype(KPermanentFileStoreLayoutUid,KSARStoreUid,iThirdUid);
   605 	TEntry entry;
   614 	TEntry entry;
   606 	TInt ret=iFs.Entry(iFullName,entry);  //  Check file exists
   615 	TInt ret=iFs.Entry(iFullName,entry);  //  Check file exists
   607 	if (ret==KErrNone)  //  File found
   616 	if (ret==KErrNone)  //  File found
   615 		// so that the trap handler will close the file
   624 		// so that the trap handler will close the file
   616 		// automatically
   625 		// automatically
   617 		TRAP(ret,(iFileStore=CPermanentFileStore::OpenL(iFs,iFullName,EFileShareExclusive|EFileStream|EFileRead|EFileWrite)));
   626 		TRAP(ret,(iFileStore=CPermanentFileStore::OpenL(iFs,iFullName,EFileShareExclusive|EFileStream|EFileRead|EFileWrite)));
   618 		if(ret != KErrNone)
   627 		if(ret != KErrNone)
   619 			{
   628 			{
   620 			OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_DOOPENL_2, "WARNING! CPermanentFileStore::OpenLC left with %d", ret);
   629 			LOGGSMU2("WARNING! CPermanentFileStore::OpenLC left with %d", ret);
   621 			}
   630 			}
   622 		}
   631 		}
   623 
   632 
   624 	if (ret==KErrNoMemory)  //  Filestore not corrupted
   633 	if (ret==KErrNoMemory)  //  Filestore not corrupted
   625 		{
   634 		{
   627 		}
   636 		}
   628 	else if (ret != KErrNone)  //  The filestore was corrupted or not found, so create a new one
   637 	else if (ret != KErrNone)  //  The filestore was corrupted or not found, so create a new one
   629 		{
   638 		{
   630 		// create a new file and push the close function on the cleanup stack,
   639 		// create a new file and push the close function on the cleanup stack,
   631 		// so that the trap handler will close the file automatically
   640 		// so that the trap handler will close the file automatically
   632 
   641 #ifdef _SMS_LOGGING_ENABLED
   633 		OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_DOOPENL_3, "CSARStore::DoOpenL(): New file created '%S'", iFullName);
   642 		TBuf8<80> buf8;
       
   643 		buf8.Copy(iFullName);
       
   644 		LOGGSMU2("CSARStore::DoOpenL(): New file created '%S'", &buf8);
       
   645 #endif
   634 		TInt kerr(iFs.MkDirAll(iFullName)); //the directory may not exist, So create one.
   646 		TInt kerr(iFs.MkDirAll(iFullName)); //the directory may not exist, So create one.
   635 		if(kerr != KErrAlreadyExists)
   647 		if(kerr != KErrAlreadyExists)
   636 			{
   648 			{
   637 			User::LeaveIfError(kerr);
   649 			User::LeaveIfError(kerr);
   638 			}
   650 			}
   652 /**
   664 /**
   653  *  Actually delete an entry in the entry array
   665  *  Actually delete an entry in the entry array
   654  */
   666  */
   655 void CSARStore::DoDeleteEntryL(TInt aIndex)
   667 void CSARStore::DoDeleteEntryL(TInt aIndex)
   656 	{
   668 	{
   657 #ifdef OST_TRACE_COMPLIER_IN_USE
   669 #ifdef _SMS_LOGGING_ENABLED
   658 	const TSmsSegmentationEntry& entry = (const TSmsSegmentationEntry&)iEntryArray[aIndex];
   670 	const TSmsSegmentationEntry& entry = (const TSmsSegmentationEntry&)iEntryArray[aIndex];
   659 
   671 
   660 	OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_DODELETEENTRYL_1, "CSARStore::DoDeleteEntryL [aIndex=%d Count=%d]",aIndex, iEntryArray.Count());
   672 	LOGGSMU3("CSARStore::DoDeleteEntryL [aIndex=%d Count=%d]",
   661 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_DODELETEENTRYL_2, "CSARStore::DoDeleteEntryL [aIndex=%d Delivered=%d Failed=%d]",aIndex, entry.Delivered(), entry.Failed());
   673 			 aIndex, iEntryArray.Count());
   662 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_DODELETEENTRYL_3, "CSARStore::DoDeleteEntryL [aIndex=%d Count=%d Total=%d]",aIndex, entry.Count(), entry.Total());
   674 	LOGGSMU4("CSARStore::DoDeleteEntryL [aIndex=%d Delivered=%d Failed=%d]",
   663 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_DODELETEENTRYL_4, "CSARStore::DoDeleteEntryL [aIndex=%d logId=%d StreamId=%u]",aIndex, entry.LogServerId(), (TUint) entry.DataStreamId().Value());
   675 			 aIndex, entry.Delivered(), entry.Failed());
   664 #endif // OST_TRACE_COMPLIER_IN_USE
   676 	LOGGSMU4("CSARStore::DoDeleteEntryL [aIndex=%d Count=%d Total=%d]",
       
   677 			 aIndex, entry.Count(), entry.Total());
       
   678 	LOGGSMU4("CSARStore::DoDeleteEntryL [aIndex=%d logId=%d StreamId=%d]",
       
   679 			 aIndex, entry.LogServerId(), entry.DataStreamId().Value());
       
   680 #endif // _SMS_LOGGING_ENABLED
   665 
   681 
   666 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   682 	__ASSERT_DEBUG(iFileStore!=NULL,Panic(KGsmuPanicSARStoreNotOpen));
   667 	TRAPD(err, iFileStore->DeleteL(iEntryArray[aIndex].DataStreamId()));
   683 	TRAPD(err, iFileStore->DeleteL(iEntryArray[aIndex].DataStreamId()));
   668 	if(err == KErrNone)
   684 	if(err == KErrNone)
   669 	    {
   685 	    {
   675 /**
   691 /**
   676  *  internalize - read from the file store into RAM
   692  *  internalize - read from the file store into RAM
   677  */
   693  */
   678 void CSARStore::InternalizeEntryArrayL()
   694 void CSARStore::InternalizeEntryArrayL()
   679 	{
   695 	{
   680 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_INTERNALIZEENTRYARRAYL_1, "CSARStore::InternalizeEntryArrayL()");
   696 	LOGGSMU1("CSARStore::InternalizeEntryArrayL()");
   681 
   697 
   682 	__ASSERT_DEBUG(iFileStore!=NULL, Panic(KGsmuPanicSARStoreNotOpen));
   698 	__ASSERT_DEBUG(iFileStore!=NULL, Panic(KGsmuPanicSARStoreNotOpen));
   683 
   699 
   684 	TStreamId headerid=iFileStore->Root();
   700 	TStreamId headerid=iFileStore->Root();
   685 	RStoreReadStream stream;
   701 	RStoreReadStream stream;
   696 	} // CSARStore::InternalizeEntryArrayL
   712 	} // CSARStore::InternalizeEntryArrayL
   697 
   713 
   698 
   714 
   699 void CSARStore::RemoveDeletedEntries()
   715 void CSARStore::RemoveDeletedEntries()
   700 	{
   716 	{
   701 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_REMOVEDELETEDENTRIES_1, "CSARStore::RemoveDeletedEntries()");
   717 	LOGGSMU1("CSARStore::RemoveDeletedEntries()");
   702 
   718 
   703 	TInt count=iEntryArray.Count();
   719 	TInt count=iEntryArray.Count();
   704 	while (count--)
   720 	while (count--)
   705 		{
   721 		{
   706 		TSAREntry& entry = iEntryArray[count];
   722 		TSAREntry& entry = iEntryArray[count];
   713 	} // CSARStore::RemoveDeletedEntries
   729 	} // CSARStore::RemoveDeletedEntries
   714 
   730 
   715 
   731 
   716 void CSARStore::ReinstateDeletedEntries()
   732 void CSARStore::ReinstateDeletedEntries()
   717 	{
   733 	{
   718 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_REINSTATEDELETEDENTRIES_1, "CSARStore::ReinstateDeletedEntries()");
   734 	LOGGSMU1("CSARStore::ReinstateDeletedEntries()");
   719 
   735 
   720 	TInt count=iEntryArray.Count();
   736 	TInt count=iEntryArray.Count();
   721 	while (count--)
   737 	while (count--)
   722 		{
   738 		{
   723 		TSAREntry& entry = iEntryArray[count];
   739 		TSAREntry& entry = iEntryArray[count];
   736 void CSARStore::ExternalizeEntryArrayL()
   752 void CSARStore::ExternalizeEntryArrayL()
   737 	{
   753 	{
   738 	__ASSERT_DEBUG(iFileStore!=NULL, Panic(KGsmuPanicSARStoreNotOpen));
   754 	__ASSERT_DEBUG(iFileStore!=NULL, Panic(KGsmuPanicSARStoreNotOpen));
   739 	__ASSERT_DEBUG(iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   755 	__ASSERT_DEBUG(iInTransaction, Panic(KGsmuPanicSARStoreTransaction));
   740 
   756 
   741 	OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_EXTERNALIZEENTRYARRAYL_1, "CSARStore::ExternalizeEntryArrayL(): this=0x%08X count=%d headerid=%u]",(TUint)this, iEntryArray.Count(), (TUint)iFileStore->Root().Value());
   757 	LOGGSMU4("CSARStore::ExternalizeEntryArrayL(): this=0x%08X count=%d headerid=%d]",
       
   758 			 this, iEntryArray.Count(), iFileStore->Root().Value());
   742 
   759 
   743 	TStreamId headerid=iFileStore->Root();
   760 	TStreamId headerid=iFileStore->Root();
   744 	RStoreWriteStream stream;
   761 	RStoreWriteStream stream;
   745 	if (headerid==KNullStreamId)
   762 	if (headerid==KNullStreamId)
   746 		{
   763 		{
   783  *  and if the store is of a certains size then
   800  *  and if the store is of a certains size then
   784  *  call CompactL also
   801  *  call CompactL also
   785  */
   802  */
   786 void CSARStore::DoCommitAndCompactL()
   803 void CSARStore::DoCommitAndCompactL()
   787 	{
   804 	{
   788 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSARSTORE_DOCOMMITANDCOMPACTL_1, "CSARStore::DoCommitAndCompactL()");
   805 	LOGGSMU1("CSARStore::DoCommitAndCompactL()");
   789 
   806 
   790 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_DEBUG) 
   807 	LOGGSMUTIMESTAMP();
   791     TBuf<40> timestamp;
       
   792     SmsTimeStampL(timestamp);
       
   793     OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS,CSARSTORE_DOCOMMITANDCOMPACTL_2, "%S",timestamp);
       
   794 #endif
       
   795 	iFileStore->CommitL();
   808 	iFileStore->CommitL();
   796 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_DEBUG) 
   809 	LOGGSMUTIMESTAMP();
   797     SmsTimeStampL(timestamp);
       
   798     OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS,CSARSTORE_DOCOMMITANDCOMPACTL_3, "%S",timestamp);
       
   799 #endif
       
   800 
   810 
   801 	iCommitCount--;
   811 	iCommitCount--;
   802 	if (iCommitCount < 0)
   812 	if (iCommitCount < 0)
   803 		{
   813 		{
   804 		iCommitCount = KNumStoreCommitsBeforeCompaction;
   814 		iCommitCount = KNumStoreCommitsBeforeCompaction;
   814  *  @param aPath The private path of a store.
   824  *  @param aPath The private path of a store.
   815  *  @capability None
   825  *  @capability None
   816  */
   826  */
   817 EXPORT_C void CSARStore::PrivatePath(TDes& aPath)
   827 EXPORT_C void CSARStore::PrivatePath(TDes& aPath)
   818 	{
   828 	{
   819 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_BORDER, CSARSTORE_PRIVATEPATH_1, "CSARStore::PrivatePath()");
   829 	LOGGSMU1("CSARStore::PrivatePath()");
   820 
   830 
   821 	TDriveUnit driveUnit(KStoreDrive);
   831 	TDriveUnit driveUnit(KStoreDrive);
   822 	TDriveName drive=driveUnit.Name();
   832 	TDriveName drive=driveUnit.Name();
   823 	aPath.Insert(0, drive);
   833 	aPath.Insert(0, drive);
   824 	//append private path
   834 	//append private path