profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp
branchRCL_3
changeset 8 f62c3a3d66b8
parent 0 8c5d936e5675
child 10 c8b9b0986973
equal deleted inserted replaced
4:3f8368f032cf 8:f62c3a3d66b8
    31 #include <MProfileTones.h>
    31 #include <MProfileTones.h>
    32 #include "CProfilesNamesArrayImpl.h"
    32 #include "CProfilesNamesArrayImpl.h"
    33 #include "CProfileImpl.h"
    33 #include "CProfileImpl.h"
    34 #include "CProfileNameImpl.h"
    34 #include "CProfileNameImpl.h"
    35 #include "ProfileEngUtils.h"
    35 #include "ProfileEngUtils.h"
    36 #include "MProfileSetName.h"
    36 #include <MProfileSetName.h>
    37 #include "ProfileEng.hrh"
    37 #include <ProfileEng.hrh>
    38 #include "ProfileEngineConstants.h"
    38 #include <ProfileEngineConstants.h>
    39 #include "ProfileEngPanic.h"
    39 #include "ProfileEngPanic.h"
    40 #include "MProfileSetTones.h"
    40 #include <MProfileSetTones.h>
    41 #include "MProfileSetExtraTones.h"
    41 #include <MProfileSetExtraTones.h>
    42 #include "MProfileExtraSettings.h"
    42 #include "MProfileExtraSettings.h"
    43 #include "MProfileFeedbackSettings.h"
    43 #include "MProfileFeedbackSettings.h"
    44 #include "MProfilesLocalFeatures.h"
    44 #include <MProfilesLocalFeatures.h>
    45 #include "MProfileUtilitySingleton.h"
    45 #include <MProfileUtilitySingleton.h>
    46 #include "ProfilesVariant.hrh" // KProEngFeatureIdVTRingingTone
    46 #include "ProfilesVariant.hrh" // KProEngFeatureIdVTRingingTone
    47 #include "CProfileTiming.h"
    47 #include "CProfileTiming.h"
    48 #include <centralrepository.h>
    48 #include <centralrepository.h>
    49 #include "ProfileEnginePrivateCRKeys.h"
    49 #include "ProfileEnginePrivateCRKeys.h"
    50 #include "ProfileEnginePrivatePSKeys.h"
    50 #include <ProfileEnginePrivatePSKeys.h>
    51 #include <hwrmvibrasdkcrkeys.h>
    51 #include <hwrmvibrasdkcrkeys.h>
    52 #include <data_caging_path_literals.hrh>
    52 #include <data_caging_path_literals.hrh>
    53 #include "ProfilesDebug.h"
    53 #include "ProfilesDebug.h"
    54 
    54 
    55 #include <psmsettings.h>
    55 #include <psmsettings.h>
   304 // -----------------------------------------------------------------------------
   304 // -----------------------------------------------------------------------------
   305 //
   305 //
   306 void CProfileEngineImpl::SetActiveProfileL( TInt aId )
   306 void CProfileEngineImpl::SetActiveProfileL( TInt aId )
   307     {
   307     {
   308     PRODEBUG1( "SetActiveProfileL( %d )", aId );
   308     PRODEBUG1( "SetActiveProfileL( %d )", aId );
       
   309     const TInt KProEngPreviousActiveNameLength( 128 );
   309     CreatePubSubKeysIfNeededL(); 
   310     CreatePubSubKeysIfNeededL(); 
   310 
   311 
   311     iMutex.Wait();
   312     iMutex.Wait();
   312     TInt err( CheckProfileIdL( aId ) );
   313     TInt err( CheckProfileIdL( aId ) );
   313 
   314     TInt nameCompare = 0;
       
   315     if( this->IsActiveProfileTimedL() )
       
   316         {
       
   317 		HBufC* tempProfileName = HBufC::NewL(KProEngPreviousActiveNameLength);
       
   318 		CleanupStack::PushL(tempProfileName);  
       
   319 		TPtr tempName = tempProfileName->Des();
       
   320 		TInt cenrepErr = iCenRep->Get( KProEngPreviousActiveName,tempName );
       
   321 		if( tempName.Length() )
       
   322 			{
       
   323 			TBuf<64> activeProfileName = this->ProfileLC(aId)->ProfileName().Name();
       
   324 			nameCompare = activeProfileName.Compare( tempName );
       
   325 			CleanupStack::PopAndDestroy();
       
   326 			}
       
   327 		CleanupStack::PopAndDestroy();
       
   328 		User::LeaveIfError( iCenRep->StartTransaction(
       
   329 											CRepository::EReadWriteTransaction ) );
       
   330 		iCenRep->CleanupCancelTransactionPushL();
       
   331 		iCenRep->Set(KProEngPreviousActiveName,_L(""));
       
   332 		TUint32 ignore( 0 );
   314     if( !err )
   333     if( !err )
       
   334 			{
       
   335 			err = iCenRep->CommitTransaction( ignore );
       
   336 			}
       
   337 		else
       
   338 			{
       
   339 			iCenRep->CancelTransaction();
       
   340 			}
       
   341 		CleanupStack::PopAndDestroy();
       
   342         }
       
   343     if( !err && !nameCompare )
   315         {
   344         {
   316         TRAP( err, DoSetActiveProfileL( aId ) );
   345         TRAP( err, DoSetActiveProfileL( aId ) );
   317         }
   346         }
   318     else
   347     else
   319         {
   348         {
   358     iMutex.Wait();
   387     iMutex.Wait();
   359     TInt err( CheckProfileIdL( aId ) );
   388     TInt err( CheckProfileIdL( aId ) );
   360 
   389 
   361     if( !err )
   390     if( !err )
   362         {
   391         {
       
   392         User::LeaveIfError( iCenRep->StartTransaction(
       
   393                         CRepository::EReadWriteTransaction ) );
       
   394         iCenRep->CleanupCancelTransactionPushL();
       
   395         iCenRep->Set(KProEngPreviousActiveName,this->ActiveProfileLC()->ProfileName().Name());
       
   396         TUint32 ignore( 0 );
       
   397         err = iCenRep->CommitTransaction( ignore );
       
   398         if( !err )
       
   399             {
   363         TRAP( err, DoSetActiveProfileL( aId, &aTime ) );
   400         TRAP( err, DoSetActiveProfileL( aId, &aTime ) );
       
   401             }
       
   402         else
       
   403         	{
       
   404         	iCenRep->CancelTransaction();
       
   405         	}
       
   406         CleanupStack::PopAndDestroy(2); 
   364         }
   407         }
   365     iMutex.Signal();
   408     iMutex.Signal();
   366 
   409 
   367     User::LeaveIfError( err );
   410     User::LeaveIfError( err );
   368     }
   411     }