Revision: 201006 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 12 Mar 2010 15:43:47 +0200
branchRCL_3
changeset 10 c8b9b0986973
parent 8 f62c3a3d66b8
child 11 23553eb4e470
Revision: 201006 Kit: 201008
profilesservices/ProfileEngine/EngInc/ProfileEnginePrivateCRKeys.h
profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp
profilesservices/ProfileEngine/EngSrc/CProfileTiming.cpp
profilesservices/ProfileEngine/EngSrc/CProfileTiming.h
profilesservices/ProfileEngine/ProfileScheduleEventSrc/CProfileChangeEvent.cpp
profilesservices/ProfileEngine/ProfileScheduleEventSrc/CProfileChangeEvent.h
profilesservices/ProfileEngine/group/ProfileScheduleEvent.mmp
--- a/profilesservices/ProfileEngine/EngInc/ProfileEnginePrivateCRKeys.h	Fri Feb 19 23:06:10 2010 +0200
+++ b/profilesservices/ProfileEngine/EngInc/ProfileEnginePrivateCRKeys.h	Fri Mar 12 15:43:47 2010 +0200
@@ -55,7 +55,13 @@
  */
 const TUint32 KProEngSchedulerTaskId       = 0x80000005;
 
+/**
+ * If the current active profile is timed, this contains the Name of the previous
+ * active profile. String.
+ * Default value: Null
+ */
 const TUint32 KProEngPreviousActiveName    = 0x80000006;
+
 //
 // The rest of the constants are used with profile-specific settings. The
 // actual key for a setting of a profile must be constructed as follows:
--- a/profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp	Fri Feb 19 23:06:10 2010 +0200
+++ b/profilesservices/ProfileEngine/EngSrc/CProfileEngineImpl.cpp	Fri Mar 12 15:43:47 2010 +0200
@@ -306,41 +306,11 @@
 void CProfileEngineImpl::SetActiveProfileL( TInt aId )
     {
     PRODEBUG1( "SetActiveProfileL( %d )", aId );
-    const TInt KProEngPreviousActiveNameLength( 128 );
     CreatePubSubKeysIfNeededL(); 
 
     iMutex.Wait();
     TInt err( CheckProfileIdL( aId ) );
-    TInt nameCompare = 0;
-    if( this->IsActiveProfileTimedL() )
-        {
-		HBufC* tempProfileName = HBufC::NewL(KProEngPreviousActiveNameLength);
-		CleanupStack::PushL(tempProfileName);  
-		TPtr tempName = tempProfileName->Des();
-		TInt cenrepErr = iCenRep->Get( KProEngPreviousActiveName,tempName );
-		if( tempName.Length() )
-			{
-			TBuf<64> activeProfileName = this->ProfileLC(aId)->ProfileName().Name();
-			nameCompare = activeProfileName.Compare( tempName );
-			CleanupStack::PopAndDestroy();
-			}
-		CleanupStack::PopAndDestroy();
-		User::LeaveIfError( iCenRep->StartTransaction(
-											CRepository::EReadWriteTransaction ) );
-		iCenRep->CleanupCancelTransactionPushL();
-		iCenRep->Set(KProEngPreviousActiveName,_L(""));
-		TUint32 ignore( 0 );
     if( !err )
-			{
-			err = iCenRep->CommitTransaction( ignore );
-			}
-		else
-			{
-			iCenRep->CancelTransaction();
-			}
-		CleanupStack::PopAndDestroy();
-        }
-    if( !err && !nameCompare )
         {
         TRAP( err, DoSetActiveProfileL( aId ) );
         }
@@ -389,21 +359,7 @@
 
     if( !err )
         {
-        User::LeaveIfError( iCenRep->StartTransaction(
-                        CRepository::EReadWriteTransaction ) );
-        iCenRep->CleanupCancelTransactionPushL();
-        iCenRep->Set(KProEngPreviousActiveName,this->ActiveProfileLC()->ProfileName().Name());
-        TUint32 ignore( 0 );
-        err = iCenRep->CommitTransaction( ignore );
-        if( !err )
-            {
         TRAP( err, DoSetActiveProfileL( aId, &aTime ) );
-            }
-        else
-        	{
-        	iCenRep->CancelTransaction();
-        	}
-        CleanupStack::PopAndDestroy(2); 
         }
     iMutex.Signal();
 
@@ -789,7 +745,9 @@
         TInt activeId( ( previousId != KErrNotFound )
                        ? previousId
                        : User::LeaveIfError( ActiveProfileId() ) );
-        iProfileTiming->SetTimedProfileL( activeId, *aTime );
+        iProfileTiming->SetTimedProfileL( activeId,
+        		                          *aTime, 
+        		                          ActiveProfileL()->ProfileName().Name() );
         }
 
     TRAPD( error, UpdateActiveProfileSettingsL( *profile, ETrue ) );
--- a/profilesservices/ProfileEngine/EngSrc/CProfileTiming.cpp	Fri Feb 19 23:06:10 2010 +0200
+++ b/profilesservices/ProfileEngine/EngSrc/CProfileTiming.cpp	Fri Mar 12 15:43:47 2010 +0200
@@ -108,7 +108,7 @@
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-void CProfileTiming::SetTimedProfileL( TInt aPreviousId, TTime aTime )
+void CProfileTiming::SetTimedProfileL( TInt aPreviousId, TTime aTime, const TDesC& aPreviousName )
     {
     PRODEBUG1( "CProfileTiming:SetTimedProfile( %d )", aPreviousId );
     if( !iFeatures.IsFeatureSupported( KProEngFeatureIdTimedProfiles ) )
@@ -158,7 +158,7 @@
             iTaskId = taskInfo.iTaskId;
             PRODEBUG( "CProfileTiming:SetTimedProfile before SaveSchedulingData" );
             SaveSchedulingData( aPreviousId, iSchedulerItemRef.iHandle,
-                                iTaskId );
+                                iTaskId, aPreviousName );
             PRODEBUG( "CProfileTiming:SetTimedProfile after SaveSchedulingData" );
             }
         }
@@ -256,10 +256,13 @@
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-void CProfileTiming::SaveSchedulingData( TInt aPreviousId, TInt aHandleId,
-                                         TInt aTaskId )
+void CProfileTiming::SaveSchedulingData( TInt aPreviousId,
+		                                 TInt aHandleId,
+                                         TInt aTaskId, 
+                                         const TDesC& aPreviousName )
     {
     iRepository.Set( KProEngSchedulerHandleId, aHandleId );
+    iRepository.Set( KProEngPreviousActiveName, aPreviousName);
     iRepository.Set( KProEngPreviousActiveId, aPreviousId );
     iRepository.Set( KProEngSchedulerTaskId, aTaskId );
     }
--- a/profilesservices/ProfileEngine/EngSrc/CProfileTiming.h	Fri Feb 19 23:06:10 2010 +0200
+++ b/profilesservices/ProfileEngine/EngSrc/CProfileTiming.h	Fri Mar 12 15:43:47 2010 +0200
@@ -62,8 +62,11 @@
          *        timer expires. This is the profile which was active before
          *        the current profile was timed.
          * @param aTime the time when the timer expires.
+		 * @param aPreviousName the Name of the profile to be activated after the
+         *        timer expires. This is the profile which was active before
+         *        the current profile was timed.
          */
-        void SetTimedProfileL( TInt aPreviousId, TTime aTime );
+        void SetTimedProfileL( TInt aPreviousId, TTime aTime, const TDesC& aPreviousName = KNullDesC );
 
         /**
          * Deletes the newly-scheduled task for timed profile. This is used
@@ -98,10 +101,12 @@
          *        when the timer goes off.
          * @param aHandleId the scheduling handle ID of the timed profile task.
          * @param aTaskId the task ID of the timed profile task.
+		 * @param aPreviousName the previous name of the timed profile task.
          */
         void SaveSchedulingData( TInt aPreviousId = -1,
                                  TInt aHandleId = -1,
-                                 TInt aTaskId = -1 );
+                                 TInt aTaskId = -1,
+                                 const TDesC& aPreviousName = KNullDesC );
 
         /**
          * Gets the information about current timed profile from Central
--- a/profilesservices/ProfileEngine/ProfileScheduleEventSrc/CProfileChangeEvent.cpp	Fri Feb 19 23:06:10 2010 +0200
+++ b/profilesservices/ProfileEngine/ProfileScheduleEventSrc/CProfileChangeEvent.cpp	Fri Mar 12 15:43:47 2010 +0200
@@ -37,6 +37,9 @@
 #include    <ProfileEngineConstants.h>
 #include    "ProfilesDebug.h"
 
+#include    <MProfileEngineExtended.h>
+#include    <MProfileExtended.h>
+#include    <MProfileName.h>
 
 // CONSTANTS
 namespace
@@ -80,7 +83,8 @@
         error = iMutex.OpenGlobal( KProfileMutexName );
         }
     User::LeaveIfError( error );
-    iProfileEngine = CreateProfileEngineL( &iFs );
+    iProfileEngine = CreateProfileEngineExtendedL( &iFs );
+    iCenRep = CRepository::NewL( KCRUidProfileEngine );
     iGlobalNote = CAknGlobalNote::NewL();
     ReadResourcesL();
     }
@@ -119,6 +123,7 @@
     {
     delete iNoteText;
     delete iGlobalNote;
+    delete iCenRep;
     if( iProfileEngine )
         {
         iProfileEngine->Release();
@@ -175,8 +180,21 @@
     {
 	PRODEBUG( " CProfileChangeEvent:ChangeProfileL" );
 
+	TBool nameEqual = EFalse;
+	HBufC* previousName = HBufC::NewL( PROFILES_MAX_NAME_LENGTH );
+	CleanupStack::PushL( previousName );  
+	TPtr tempName = previousName->Des();
+	User::LeaveIfError( iCenRep->Get( KProEngPreviousActiveName, tempName ) );
+	if( tempName.Length() )
+		{
+		nameEqual = tempName.Compare( iProfileEngine->ProfileL( iPreviousId )->ProfileName().Name() );
+		}
+	if( !nameEqual )
+		{
     iProfileEngine->SetActiveProfileL( iPreviousId );
-
+		}
+	User::LeaveIfError( iCenRep->Set( KProEngPreviousActiveName, KNullDesC ) );
+	CleanupStack::PopAndDestroy();
     }
 
 // -----------------------------------------------------------------------------
--- a/profilesservices/ProfileEngine/ProfileScheduleEventSrc/CProfileChangeEvent.h	Fri Feb 19 23:06:10 2010 +0200
+++ b/profilesservices/ProfileEngine/ProfileScheduleEventSrc/CProfileChangeEvent.h	Fri Mar 12 15:43:47 2010 +0200
@@ -26,8 +26,9 @@
 #include <f32file.h>
 
 // FORWARD DECLARATIONS
-class MProfileEngine;
+class MProfileEngineExtended;
 class CAknGlobalNote;
+class CRepository;
 
 // CLASS DECLARATION
 
@@ -109,7 +110,7 @@
 
     private:    // Data
         // Own: Profiles Engine for profile activation
-        MProfileEngine* iProfileEngine;
+    	MProfileEngineExtended* iProfileEngine;
 
         // Own: Global note to show the expiration conf. note to the user
         CAknGlobalNote* iGlobalNote;
@@ -131,6 +132,9 @@
         
         // Supported features
         TBool iCoverDisplay;
+        
+        // Central Repository
+        CRepository* iCenRep;
     };
 
 #endif      // CPROFILECHANGEEVENT_H
--- a/profilesservices/ProfileEngine/group/ProfileScheduleEvent.mmp	Fri Feb 19 23:06:10 2010 +0200
+++ b/profilesservices/ProfileEngine/group/ProfileScheduleEvent.mmp	Fri Mar 12 15:43:47 2010 +0200
@@ -41,7 +41,7 @@
 
 USERINCLUDE     . ../EngInc ../../group
 
-MW_LAYER_SYSTEMINCLUDE
+APP_LAYER_SYSTEMINCLUDE
 
 LIBRARY         euser.lib
 LIBRARY         commonengine.lib