convergedcallengine/cenrepdatabase/src/cenrepdatabaseutil.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
   142 EXPORT_C void CCenRepDatabaseUtil::BeginTransactionL()
   142 EXPORT_C void CCenRepDatabaseUtil::BeginTransactionL()
   143     {
   143     {
   144     CENREPDATABASELOG( "CCenRepDatabaseUtil::BeginTransactionL - IN" );
   144     CENREPDATABASELOG( "CCenRepDatabaseUtil::BeginTransactionL - IN" );
   145     
   145     
   146     iSemaphore.Wait();
   146     iSemaphore.Wait();
   147     TCleanupItem cleanup( CCenRepDatabaseUtil::ReleaseSemaphore, this );
   147 	TCleanupItem cleanup( CCenRepDatabaseUtil::ReleaseSemaphore, this );
   148     CleanupStack::PushL( cleanup );
   148 	CleanupStack::PushL( cleanup );
   149     
   149     
   150     User::LeaveIfError( 
   150     User::LeaveIfError( 
   151         iRepository->StartTransaction( CRepository::EReadWriteTransaction ) );
   151         iRepository->StartTransaction( CRepository::EReadWriteTransaction ) );
   152     
   152     
   153     iRepository->CleanupRollbackTransactionPushL(); // if leave happens,
   153 	iRepository->CleanupRollbackTransactionPushL(); // if leave happens,
   154                                                     // only roll back, no delete
   154 	                                                // only roll back, no delete
   155     
   155 	
   156     CENREPDATABASELOG( "CCenRepDatabaseUtil::BeginTransactionL - OUT" );                                                
   156 	CENREPDATABASELOG( "CCenRepDatabaseUtil::BeginTransactionL - OUT" );                                                
   157     }
   157     }
   158 
   158 
   159 // ---------------------------------------------------------------------------
   159 // ---------------------------------------------------------------------------
   160 // Commits changes in repository.
   160 // Commits changes in repository.
   161 // ---------------------------------------------------------------------------
   161 // ---------------------------------------------------------------------------
   162 //
   162 //
   163 EXPORT_C TInt CCenRepDatabaseUtil::CommitTransaction()
   163 EXPORT_C TInt CCenRepDatabaseUtil::CommitTransaction()
   164     {
   164     {
   165     CENREPDATABASELOG( "CCenRepDatabaseUtil::CommitTransaction - IN" );
   165     CENREPDATABASELOG( "CCenRepDatabaseUtil::CommitTransaction - IN" );
   166     
   166     
   167     TUint32 temp;
   167 	TUint32 temp;
   168     
   168 	
   169     TInt retval = iRepository->CommitTransaction( temp );
   169 	TInt retval = iRepository->CommitTransaction( temp );
   170     
   170 	
   171     iSemaphore.Signal();
   171 	iSemaphore.Signal();
   172 
   172 
   173     CleanupStack::Pop( 2 ); // semaphore and repository
   173 	CleanupStack::Pop( 2 ); // semaphore and repository
   174     
   174 	
   175     CENREPDATABASELOG( "CCenRepDatabaseUtil::CommitTransaction - OUT" );
   175 	CENREPDATABASELOG( "CCenRepDatabaseUtil::CommitTransaction - OUT" );
   176 
   176 
   177     return retval;
   177     return retval;
   178     }
   178     }
   179 
   179 
   180 // ---------------------------------------------------------------------------
   180 // ---------------------------------------------------------------------------
   183 //
   183 //
   184 EXPORT_C void CCenRepDatabaseUtil::RollbackTransaction()
   184 EXPORT_C void CCenRepDatabaseUtil::RollbackTransaction()
   185     {
   185     {
   186     CENREPDATABASELOG( "CCenRepDatabaseUtil::RollbackTransaction - IN" );
   186     CENREPDATABASELOG( "CCenRepDatabaseUtil::RollbackTransaction - IN" );
   187     
   187     
   188     CleanupStack::Pop( 2 ); // rollback transaction item and semaphore
   188 	CleanupStack::Pop( 2 ); // rollback transaction item and semaphore
   189 
   189 
   190     iRepository->RollbackTransaction();
   190 	iRepository->RollbackTransaction();
   191     iSemaphore.Signal();
   191 	iSemaphore.Signal();
   192     
   192 	
   193     CENREPDATABASELOG( "CCenRepDatabaseUtil::RollbackTransaction - OUT" );
   193 	CENREPDATABASELOG( "CCenRepDatabaseUtil::RollbackTransaction - OUT" );
   194     }
   194     }
   195     
   195     
   196 // ---------------------------------------------------------------------------
   196 // ---------------------------------------------------------------------------
   197 // Add new entry to cenrep.
   197 // Add new entry to cenrep.
   198 // ---------------------------------------------------------------------------
   198 // ---------------------------------------------------------------------------
   598 // ---------------------------------------------------------------------------
   598 // ---------------------------------------------------------------------------
   599 // Release semaphore, this function is used in custom cleanup
   599 // Release semaphore, this function is used in custom cleanup
   600 // ---------------------------------------------------------------------------
   600 // ---------------------------------------------------------------------------
   601 //
   601 //
   602 void CCenRepDatabaseUtil::ReleaseSemaphore( TAny* aPtr )
   602 void CCenRepDatabaseUtil::ReleaseSemaphore( TAny* aPtr )
   603     {
   603 	{
   604     CENREPDATABASELOG( "CCenRepDatabaseUtil::ReleaseSemaphore - IN" );
   604 	CENREPDATABASELOG( "CCenRepDatabaseUtil::ReleaseSemaphore - IN" );
   605     
   605 	
   606     ASSERT ( aPtr );
   606 	ASSERT ( aPtr );
   607     CCenRepDatabaseUtil* utils = static_cast<CCenRepDatabaseUtil*>( aPtr );
   607 	CCenRepDatabaseUtil* utils = static_cast<CCenRepDatabaseUtil*>( aPtr );
   608     utils->DoReleaseSemaphore();
   608 	utils->DoReleaseSemaphore();
   609     
   609 	
   610     CENREPDATABASELOG( "CCenRepDatabaseUtil::ReleaseSemaphore - OUT" );
   610 	CENREPDATABASELOG( "CCenRepDatabaseUtil::ReleaseSemaphore - OUT" );
   611     }
   611 	}
   612 
   612 
   613 // ---------------------------------------------------------------------------
   613 // ---------------------------------------------------------------------------
   614 // Release semaphore
   614 // Release semaphore
   615 // ---------------------------------------------------------------------------
   615 // ---------------------------------------------------------------------------
   616 //
   616 //
   617 void CCenRepDatabaseUtil::DoReleaseSemaphore()
   617 void CCenRepDatabaseUtil::DoReleaseSemaphore()
   618     {
   618 	{
   619     CENREPDATABASELOG( "CCenRepDatabaseUtil::DoReleaseSemaphore - IN" );
   619 	CENREPDATABASELOG( "CCenRepDatabaseUtil::DoReleaseSemaphore - IN" );
   620     
   620 	
   621     iSemaphore.Signal();
   621 	iSemaphore.Signal();
   622     
   622 	
   623     CENREPDATABASELOG( "CCenRepDatabaseUtil::DoReleaseSemaphore - OUT" );
   623 	CENREPDATABASELOG( "CCenRepDatabaseUtil::DoReleaseSemaphore - OUT" );
   624     }
   624 	}
   625 
   625 
   626 // ---------------------------------------------------------------------------
   626 // ---------------------------------------------------------------------------
   627 // Set value of key or create a new one.
   627 // Set value of key or create a new one.
   628 // ---------------------------------------------------------------------------
   628 // ---------------------------------------------------------------------------
   629 //
   629 //
   711             {
   711             {
   712             User::Leave( err1 );
   712             User::Leave( err1 );
   713             }
   713             }
   714         }
   714         }
   715     else
   715     else
   716         {
   716     	{
   717         User::Leave( err );
   717     	User::Leave( err );
   718         }
   718     	}
   719 
   719 
   720     CleanupStack::PopAndDestroy( &keys );
   720     CleanupStack::PopAndDestroy( &keys );
   721 
   721 
   722     return idKey;
   722     return idKey;
   723     }
   723     }
   775     TInt aEntryId, 
   775     TInt aEntryId, 
   776     const RIpAppPropArray& aPropertyArray, 
   776     const RIpAppPropArray& aPropertyArray, 
   777     TBool& aOk )
   777     TBool& aOk )
   778     {
   778     {
   779     RIpAppPropArray allArray;
   779     RIpAppPropArray allArray;
   780     TCleanupItem cleanup( CCenRepDatabaseUtil::CleanupPointerArray, &allArray );
   780 	TCleanupItem cleanup( CCenRepDatabaseUtil::CleanupPointerArray, &allArray );
   781     CleanupStack::PushL( cleanup );
   781 	CleanupStack::PushL( cleanup );
   782     
   782     
   783     TInt err = FindEntryL( aEntryId, allArray );
   783     TInt err = FindEntryL( aEntryId, allArray );
   784     if( err == KErrNone )
   784     if( err == KErrNone )
   785         {
   785         {
   786         aOk = ETrue;
   786         aOk = ETrue;
   821 // ---------------------------------------------------------------------------
   821 // ---------------------------------------------------------------------------
   822 // Cleanup array of properties.
   822 // Cleanup array of properties.
   823 // ---------------------------------------------------------------------------
   823 // ---------------------------------------------------------------------------
   824 //
   824 //
   825 void CCenRepDatabaseUtil::CleanupPointerArray(  TAny* aPointer )
   825 void CCenRepDatabaseUtil::CleanupPointerArray(  TAny* aPointer )
   826     {
   826 	{
   827     RIpAppPropArray* array = static_cast<RIpAppPropArray*>( aPointer );
   827 	RIpAppPropArray* array = static_cast<RIpAppPropArray*>( aPointer );
   828     array->ResetAndDestroy();
   828 	array->ResetAndDestroy();
   829     }
   829 	}
   830     
   830     
   831 
   831 
   832 
   832