clock/clockengines/clockserver/server/src/clockserverimpl.cpp
changeset 37 360d55486d7f
parent 32 ea672fcb0ea0
child 49 5de72ea7a065
--- a/clock/clockengines/clockserver/server/src/clockserverimpl.cpp	Thu May 27 12:51:15 2010 +0300
+++ b/clock/clockengines/clockserver/server/src/clockserverimpl.cpp	Fri Jun 11 13:37:54 2010 +0300
@@ -31,7 +31,6 @@
 #include "clockservermccobserver.h"
 #include "clockecomlistener.h"
 #include "clock_debug.h"
-#include "clockprivatecrkeys.h"
 
 // Constants
 const TInt KZeroIndex( 0 );
@@ -519,29 +518,14 @@
 	// Set a flag saying we have plugin data.
 	iPluginData = ETrue;
 	
-	// Get the first boot status from cenrep. If it is the first boot, clockserver will not update the time.
-	TBool staleBoot( EFalse );
-	
-	CRepository* cenRep( NULL );
-
-	TRAPD( errorVal, cenRep = CRepository::NewL( KCRUidStartup ) );
-	
-	if( errorVal == KErrNone )
-		{
-		errorVal = cenRep->Get( KStartupFirstBoot, staleBoot );
-		}
-	
-	// Cleanup.
-	delete cenRep;
-	cenRep = NULL;
-	
 	if( iMccReceived )
 		{
 		__PRINTS( "We have already recieved the MCC" );
 		
 		// Try to resolve the timezone id with the data that we have recieved.
 		TInt timezoneId;
-		TRAP_IGNORE( TInt errorVal = iTzResolver->GetTimeZoneL( *iTimeAttributes, iMcc, timezoneId ) );
+		 TInt errorVal;
+		TRAP_IGNORE( errorVal = iTzResolver->GetTimeZoneL( *iTimeAttributes, iMcc, timezoneId ) );
 		
 		__PRINT( "CClkSrvImpl::NotifyTimeChangeL - timeZoneId: %d", timezoneId );
 		
@@ -564,24 +548,6 @@
 			if( KInvalidTimeZoneId != timezoneId ) 
 				{
                 // A valid new zone was found successfully
-			
-                // Update the key for ValidNitz for the first boot
-                if(!staleBoot)
-                    {
-                    TInt validNitz( KSetValidNitz );
-                    CRepository* cenRep( NULL );
-    
-                    TRAPD( errorVal, cenRep =
-                    		CRepository::NewL( TUid::Uid(KCRUidNitz) ) );
-                    if( errorVal == KErrNone )
-                        {
-                        errorVal = cenRep->Set( KValidNitz, validNitz );
-                        }
-                    // Cleanup.
-                    delete cenRep;
-                    cenRep = NULL;
-                    }
-			    
 				CTzId* newTzId = CTzId::NewL( timezoneId );
 				CleanupStack::PushL( newTzId );
 
@@ -593,12 +559,9 @@
 					{
 					// The new zone is different than the current one
 					// GOAL 3: Set the DST zone of the device
-					//if( staleBoot )
-					//{
-						__PRINTS( "Not the first boot and the timezone ID is different. Setting the zone." );
+					__PRINTS( "Timezone ID is different. Setting the zone." );
 						
-						TRAP_IGNORE( tz.SetTimeZoneL( *newTzId ) );
-					//	}
+					TRAP_IGNORE( tz.SetTimeZoneL( *newTzId ) );
 					}
 
 				CleanupStack::PopAndDestroy( newTzId );
@@ -613,12 +576,9 @@
 			// Set the UTC time only. This is being done because with the UTC time,
 			// before the time is being set, the dst properties for the timezone are being checked.
 			// If its not the first boot, then set the time.
-			//if( staleBoot )
-			//	{
-				__PRINTS( "Not the first boot. Setting the UTC time." );
+			__PRINTS( "Setting the UTC time." );
 				
-				TRAP_IGNORE( User::SetUTCTime( nwUtcTime ) );
-			//	}
+			TRAP_IGNORE( User::SetUTCTime( nwUtcTime ) );
 			}
 		
 		// Reset the flags.
@@ -634,8 +594,9 @@
 		
 		// Try to resolve the timezone id with the data that we have recieved.
 		TInt timezoneId;
+		TInt errorVal;
 		const TBuf< 4 > invalidMCC( KInvalidMCC );
-		TRAP_IGNORE( TInt errorVal = iTzResolver->GetTimeZoneL( *iTimeAttributes, invalidMCC, timezoneId ) );
+		TRAP_IGNORE( errorVal = iTzResolver->GetTimeZoneL( *iTimeAttributes, invalidMCC, timezoneId ) );
 		
 		if( KErrNone == errorVal )
 			{
@@ -650,24 +611,6 @@
 			if( KInvalidTimeZoneId != timezoneId ) 
 				{
                 // A valid new zone was found successfully
-			
-	            // Update the key for ValidNitz for the first boot
-                if(!staleBoot)
-                    {
-                    TInt validNitz( KSetValidNitz );
-                    CRepository* cenRep( NULL );
-    
-                    TRAPD( errorVal, cenRep =
-                    		CRepository::NewL( TUid::Uid(KCRUidNitz) ) );
-                    if( errorVal == KErrNone )
-                        {
-                        errorVal = cenRep->Set( KValidNitz, validNitz );
-                        }
-                    // Cleanup.
-                    delete cenRep;
-                    cenRep = NULL;
-                    }
-			
 				CTzId* newTzId = CTzId::NewL( timezoneId );
 				CleanupStack::PushL( newTzId );
 
@@ -676,12 +619,9 @@
 					// The new zone is different than the current one
 					// GOAL 3: Set the DST zone of the device
 					// If firstboot then don't set the time.
-					//if( staleBoot )
-					//	{
-						__PRINTS( "Not the first boot and the timezone ID is different. Setting the zone." );
+					__PRINTS( "The timezone ID is different. Setting the zone." );
 						
-						TRAP_IGNORE( tz.SetTimeZoneL( *newTzId ) );
-					//	}
+					TRAP_IGNORE( tz.SetTimeZoneL( *newTzId ) );
 					}
 				CleanupStack::PopAndDestroy( newTzId );
 				}
@@ -695,12 +635,9 @@
 			// Set the UTC time only. This is being done because with the UTC time,
 			// before the time is being set, the dst properties for the timezone are being checked.
 			// Set the time only if its not the first boot.
-			//if( staleBoot )
-			//    {
-			    __PRINTS( "Not the first boot. Setting the UTC time." );
+			__PRINTS( "Setting the UTC time." );
 
-			    TRAP_IGNORE( User::SetUTCTime( nwUtcTime ) );
-			//    }
+			TRAP_IGNORE( User::SetUTCTime( nwUtcTime ) );
 			}
 		}
 	__PRINTS( "Notifying the timechange to client" );
@@ -738,23 +675,6 @@
 		// Try and fetch the timezone ID using the MCC recieved.
 		TRAP_IGNORE( iTzResolver->TzIdFromMccL( iMcc, tzIdArray, KInvalidTimeZoneId ) );
 		
-		// Code to check if its the first boot.
-		// Get the first boot status from cenrep. If it is the first boot, clockserver will not update the time.
-		TBool staleBoot( EFalse );
-		
-		CRepository* cenRep( NULL );
-
-		TRAPD( errorVal, cenRep = CRepository::NewL( KCRUidStartup ) );
-		
-		if( errorVal == KErrNone )
-			{
-			errorVal = cenRep->Get( KStartupFirstBoot, staleBoot );
-			}
-		
-		// Cleanup
-		delete cenRep;
-		cenRep = NULL;
-	
 		// A single matching timezone was found. Set it as the default one.
 		if( KSingleZone == tzIdArray.Count() )
 			{
@@ -782,12 +702,9 @@
 					// The new zone is different than the current one
 					// Set the DST zone of the device
 					// Set the zone only for subsequent boots.
-					if( staleBoot )
-						{
-						__PRINTS( "Not the first boot and the timezone ID is different. Setting the zone." );
+					__PRINTS( "The timezone ID is different. Setting the zone." );
 						
-						TRAP_IGNORE( tz.SetTimeZoneL( *newTzId ) );
-						}
+					TRAP_IGNORE( tz.SetTimeZoneL( *newTzId ) );
 					}
 				CleanupStack::PopAndDestroy( newTzId );
 				}