profilesservices/ProfileEngine/ProfileScheduleEventSrc/CProfileChangeEvent.cpp
branchRCL_3
changeset 13 23553eb4e470
parent 12 c8b9b0986973
child 16 bdac6c462392
equal deleted inserted replaced
12:c8b9b0986973 13:23553eb4e470
    26 #include    <data_caging_path_literals.hrh>
    26 #include    <data_caging_path_literals.hrh>
    27 #include    <centralrepository.h>
    27 #include    <centralrepository.h>
    28 #include    <barsc.h>
    28 #include    <barsc.h>
    29 #include    <bautils.h>
    29 #include    <bautils.h>
    30 
    30 
    31 #include	<SecondaryDisplay/SecondaryDisplayProfilesAPI.h>
    31 #include	<secondarydisplay\SecondaryDisplayProfilesAPI.h>
    32 #include	<aknSDData.h>
    32 #include	<aknSDData.h>
    33 #include	<featmgr.h>
    33 #include	<featmgr.h>
    34 
    34 
    35 #include    <ProfileScheduleEvent.rsg>
    35 #include    <ProfileScheduleEvent.rsg>
    36 #include    "ProfileEnginePrivateCRKeys.h"
    36 #include    "ProfileEnginePrivateCRKeys.h"
    37 #include    <ProfileEngineConstants.h>
    37 #include    <ProfileEngineConstants.h>
    38 #include    "ProfilesDebug.h"
    38 #include    "ProfilesDebug.h"
    39 
    39 
    40 #include    <MProfileEngineExtended.h>
       
    41 #include    <MProfileExtended.h>
       
    42 #include    <MProfileName.h>
       
    43 
    40 
    44 // CONSTANTS
    41 // CONSTANTS
    45 namespace
    42 namespace
    46     {
    43     {
    47     _LIT( KProfileScheduleEventResourceDriveAndDir, "Z:ProfileScheduleEvent.rsc" );
    44     _LIT( KProfileScheduleEventResourceDriveAndDir, "Z:ProfileScheduleEvent.rsc" );
    81             break;
    78             break;
    82             }
    79             }
    83         error = iMutex.OpenGlobal( KProfileMutexName );
    80         error = iMutex.OpenGlobal( KProfileMutexName );
    84         }
    81         }
    85     User::LeaveIfError( error );
    82     User::LeaveIfError( error );
    86     iProfileEngine = CreateProfileEngineExtendedL( &iFs );
    83     iProfileEngine = CreateProfileEngineL( &iFs );
    87     iCenRep = CRepository::NewL( KCRUidProfileEngine );
       
    88     iGlobalNote = CAknGlobalNote::NewL();
    84     iGlobalNote = CAknGlobalNote::NewL();
    89     ReadResourcesL();
    85     ReadResourcesL();
    90     }
    86     }
    91 
    87 
    92 // -----------------------------------------------------------------------------
    88 // -----------------------------------------------------------------------------
   121 // Destructor
   117 // Destructor
   122 CProfileChangeEvent::~CProfileChangeEvent()
   118 CProfileChangeEvent::~CProfileChangeEvent()
   123     {
   119     {
   124     delete iNoteText;
   120     delete iNoteText;
   125     delete iGlobalNote;
   121     delete iGlobalNote;
   126     delete iCenRep;
       
   127     if( iProfileEngine )
   122     if( iProfileEngine )
   128         {
   123         {
   129         iProfileEngine->Release();
   124         iProfileEngine->Release();
   130         }
   125         }
   131     iFs.Close();
   126     iFs.Close();
   178 //
   173 //
   179 void CProfileChangeEvent::ChangeProfileL()
   174 void CProfileChangeEvent::ChangeProfileL()
   180     {
   175     {
   181 	PRODEBUG( " CProfileChangeEvent:ChangeProfileL" );
   176 	PRODEBUG( " CProfileChangeEvent:ChangeProfileL" );
   182 
   177 
   183 	TBool nameEqual = EFalse;
       
   184 	HBufC* previousName = HBufC::NewL( PROFILES_MAX_NAME_LENGTH );
       
   185 	CleanupStack::PushL( previousName );  
       
   186 	TPtr tempName = previousName->Des();
       
   187 	User::LeaveIfError( iCenRep->Get( KProEngPreviousActiveName, tempName ) );
       
   188 	if( tempName.Length() )
       
   189 		{
       
   190 		nameEqual = tempName.Compare( iProfileEngine->ProfileL( iPreviousId )->ProfileName().Name() );
       
   191 		}
       
   192 	if( !nameEqual )
       
   193 		{
       
   194     iProfileEngine->SetActiveProfileL( iPreviousId );
   178     iProfileEngine->SetActiveProfileL( iPreviousId );
   195 		}
   179 
   196 	User::LeaveIfError( iCenRep->Set( KProEngPreviousActiveName, KNullDesC ) );
       
   197 	CleanupStack::PopAndDestroy();
       
   198     }
   180     }
   199 
   181 
   200 // -----------------------------------------------------------------------------
   182 // -----------------------------------------------------------------------------
   201 // CProfileChangeEvent::ReadProfileIdL
   183 // CProfileChangeEvent::ReadProfileIdL
   202 // (other items were commented in a header).
   184 // (other items were commented in a header).