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