tzservices/tzserver/Server/Source/tzlocalizationdb.cpp
changeset 81 676b6116ca93
parent 0 2e3d3ce01487
equal deleted inserted replaced
78:175a0d824084 81:676b6116ca93
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    22 #include <tzusernames.h>//new file added for CTzUserNames which is publishedPartner
    22 #include <tzusernames.h>//new file added for CTzUserNames which is publishedPartner
    23 #endif
    23 #endif
    24 #include <tzlocalizedcityrecord.h>
    24 #include <tzlocalizedcityrecord.h>
    25 #include <tzlocalizedtimezonerecord.h>
    25 #include <tzlocalizedtimezonerecord.h>
       
    26 #include "OstTraceDefinitions.h"
       
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "tzlocalizationdbTraces.h"
       
    29 #endif
       
    30 
    26 
    31 
    27 // Database location and access policy
    32 // Database location and access policy
    28 _LIT(KTzLocalizationDbName,"c:TzLocalization.db");
    33 _LIT(KTzLocalizationDbName,"c:TzLocalization.db");
    29 _LIT(KTzLocalizationDbSecurityPolicy,"secure[10206A8B]");
    34 _LIT(KTzLocalizationDbSecurityPolicy,"secure[10206A8B]");
    30 
    35 
   113 	iServer.UserTimeZoneDb().AddObserverL(this);
   118 	iServer.UserTimeZoneDb().AddObserverL(this);
   114 	}
   119 	}
   115 
   120 
   116 void CTzLocalizationDb::OpenDbL()
   121 void CTzLocalizationDb::OpenDbL()
   117 	{
   122 	{
       
   123     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_OPENDBL_ENTRY, "CTzLocalizationDb::OpenDbL Entry" );
       
   124     
   118 	if (iZoneMutex.OpenGlobal(KTzMutexName) != KErrNone)
   125 	if (iZoneMutex.OpenGlobal(KTzMutexName) != KErrNone)
   119 		{
   126 		{
   120 		User::LeaveIfError(iZoneMutex.CreateGlobal(KTzMutexName)) ;
   127 		User::LeaveIfError(iZoneMutex.CreateGlobal(KTzMutexName)) ;
   121 		}
   128 		}
   122 	//Attempt to open the database
   129 	//Attempt to open the database
   140 		}
   147 		}
   141 	else if (error != KErrNone)
   148 	else if (error != KErrNone)
   142 		{
   149 		{
   143 		User::Leave(error);
   150 		User::Leave(error);
   144 		}
   151 		}
       
   152 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_OPENDBL_EXIT, "CTzLocalizationDb::OpenDbL Exit" );
       
   153 	
   145 	}
   154 	}
   146 
   155 
   147 void CTzLocalizationDb::CloseDb()
   156 void CTzLocalizationDb::CloseDb()
   148     {
   157     {
   149 	iLocalizedTimeZoneDb.Close();
   158 	iLocalizedTimeZoneDb.Close();
   166 @return KErrNone if succesful, or one of the DBMS Leave codes
   175 @return KErrNone if succesful, or one of the DBMS Leave codes
   167 @internalTechnology
   176 @internalTechnology
   168 */
   177 */
   169 void CTzLocalizationDb::CreateBlankFrequentlyUsedZoneTableL()
   178 void CTzLocalizationDb::CreateBlankFrequentlyUsedZoneTableL()
   170 	{
   179 	{
       
   180     OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_CREATEBLANKFREQUENTLYUSEDZONETABLEL_ENTRY, "CTzLocalizationDb::CreateBlankFrequentlyUsedZoneTableL Entry" );
       
   181     
   171 	// Create the columns for the cached zones table
   182 	// Create the columns for the cached zones table
   172 	RArray<TDbCol> cachedTableCols;
   183 	RArray<TDbCol> cachedTableCols;
   173 	CleanupClosePushL(cachedTableCols);
   184 	CleanupClosePushL(cachedTableCols);
   174 	cachedTableCols.AppendL(TDbCol(KCZTableTzIdCol,			EDbColUint16));
   185 	cachedTableCols.AppendL(TDbCol(KCZTableTzIdCol,			EDbColUint16));
   175 	cachedTableCols.AppendL(TDbCol(KCZTableStdCol, 			EDbColText));
   186 	cachedTableCols.AppendL(TDbCol(KCZTableStdCol, 			EDbColText));
   224 		}
   235 		}
   225 	
   236 	
   226 	CleanupStack::PopAndDestroy(&zoneView);
   237 	CleanupStack::PopAndDestroy(&zoneView);
   227 	CleanupStack::PopAndDestroy(frequentlyUsedZoneColSet);
   238 	CleanupStack::PopAndDestroy(frequentlyUsedZoneColSet);
   228 	CleanupStack::PopAndDestroy(&cachedTableCols); //cachedTableCols
   239 	CleanupStack::PopAndDestroy(&cachedTableCols); //cachedTableCols
       
   240 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_CREATEBLANKFREQUENTLYUSEDZONETABLEL_EXIT, "CTzLocalizationDb::CreateBlankFrequentlyUsedZoneTableL Exit" );
       
   241 	
   229 	}
   242 	}
   230 
   243 
   231 /**
   244 /**
   232 Creates the user added city database table.
   245 Creates the user added city database table.
   233 @return KErrNone if succesful, or one of the DBMS Leave codes
   246 @return KErrNone if succesful, or one of the DBMS Leave codes
   260 	}
   273 	}
   261 
   274 
   262 //Check if the database is corrupt or invalid.
   275 //Check if the database is corrupt or invalid.
   263 TBool CTzLocalizationDb::IsInvalidL()
   276 TBool CTzLocalizationDb::IsInvalidL()
   264 	{
   277 	{
       
   278     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_ISINVALIDL_ENTRY, "CTzLocalizationDb::IsInvalidL Entry" );
       
   279     
       
   280     
   265 	RDbView zoneView;
   281 	RDbView zoneView;
   266 	CleanupClosePushL(zoneView);
   282 	CleanupClosePushL(zoneView);
   267 	PrepareZoneViewL(zoneView);
   283 	PrepareZoneViewL(zoneView);
   268 	TBool isInvalid = EFalse;
   284 	TBool isInvalid = EFalse;
   269 	if (!zoneView.FirstL())
   285 	if (!zoneView.FirstL())
   280 			    break;
   296 			    break;
   281 		        }
   297 		        }
   282 		    }
   298 		    }
   283 		}
   299 		}
   284 	CleanupStack::PopAndDestroy(&zoneView);
   300 	CleanupStack::PopAndDestroy(&zoneView);
       
   301 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_ISINVALIDL_EXIT, "CTzLocalizationDb::IsInvalidL Exit;isInvalid=%u", isInvalid );
       
   302 	
   285 	return isInvalid;
   303 	return isInvalid;
   286 	}
   304 	}
   287 
   305 
   288 void CTzLocalizationDb::RecreateBlankDatabaseL()
   306 void CTzLocalizationDb::RecreateBlankDatabaseL()
   289 	{
   307 	{
   314 	// Do nothing as we don't use any rules information
   332 	// Do nothing as we don't use any rules information
   315 	}
   333 	}
   316 
   334 
   317 void CTzLocalizationDb::NotifyUserTzNamesChange(TTzUserDataChange aChange)
   335 void CTzLocalizationDb::NotifyUserTzNamesChange(TTzUserDataChange aChange)
   318 	{
   336 	{
       
   337     OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYUSERTZNAMESCHANGE_ENTRY, "CTzLocalizationDb::NotifyUserTzNamesChange Entry" );
       
   338     
   319 	if (iLocked)
   339 	if (iLocked)
   320 		{
   340 		{
       
   341 	    OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYUSERTZNAMESCHANGE_EXIT, "CTzLocalizationDb::NotifyUserTzNamesChange Exit" );
       
   342 	    
   321 		return;
   343 		return;
   322 		}
   344 		}
   323 	
   345 	
   324 	if (aChange.iOperation == ETzUserDataCreated)
   346 	if (aChange.iOperation == ETzUserDataCreated)
   325 		{
   347 		{
   326 		// Creation of new zones has no impact on existing zones
   348 		// Creation of new zones has no impact on existing zones
       
   349 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYUSERTZNAMESCHANGE_EXIT3, "CTzLocalizationDb::NotifyUserTzNamesChange Exit" );
       
   350 	    
   327 		return;
   351 		return;
   328 		}
   352 		}
   329 	
   353 	
   330 	// Iterate through the tables and refresh contents if needed
   354 	// Iterate through the tables and refresh contents if needed
   331 	TRAPD(err, NotifyUserTzNamesChangeL(aChange));
   355 	TRAPD(err, NotifyUserTzNamesChangeL(aChange));
   334 		// If there has been an error we can't guarantee the contents of the
   358 		// If there has been an error we can't guarantee the contents of the
   335 		// database. Safest option is to lock it. The only way to unlock it
   359 		// database. Safest option is to lock it. The only way to unlock it
   336 		// is to reboot the server.
   360 		// is to reboot the server.
   337 		iLocked = ETrue;
   361 		iLocked = ETrue;
   338 		}
   362 		}
       
   363 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYUSERTZNAMESCHANGE_EXIT2, "CTzLocalizationDb::NotifyUserTzNamesChange Exit" );
       
   364 	
   339 	}
   365 	}
   340 
   366 
   341 void CTzLocalizationDb::NotifyTZDataStatusChangeL(RTz::TTzChanges aChange)
   367 void CTzLocalizationDb::NotifyTZDataStatusChangeL(RTz::TTzChanges aChange)
   342 	{
   368 	{
       
   369     OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYTZDATASTATUSCHANGEL_ENTRY, "CTzLocalizationDb::NotifyTZDataStatusChangeL;aChange=%u", aChange );
       
   370     
   343 	if (iLocked)
   371 	if (iLocked)
   344 		{
   372 		{
       
   373 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYTZDATASTATUSCHANGEL_EXIT, "CTzLocalizationDb::NotifyTZDataStatusChangeL Exit" );
       
   374 	    
   345 		return;
   375 		return;
   346 		}
   376 		}
   347 	
   377 	
   348 	if(aChange == RTz::ETZLocalizationDataChanged)
   378 	if(aChange == RTz::ETZLocalizationDataChanged)
   349 		{
   379 		{
   424 		CleanupStack::PopAndDestroy(&cityView);
   454 		CleanupStack::PopAndDestroy(&cityView);
   425 		CleanupStack::PopAndDestroy(&cachedCities); 
   455 		CleanupStack::PopAndDestroy(&cachedCities); 
   426 		CleanupStack::PopAndDestroy(&frequentlyUsedZones); 
   456 		CleanupStack::PopAndDestroy(&frequentlyUsedZones); 
   427 		CleanupStack::PopAndDestroy(systemDataDb);
   457 		CleanupStack::PopAndDestroy(systemDataDb);
   428 		}
   458 		}
       
   459 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYTZDATASTATUSCHANGEL_EXIT2, "CTzLocalizationDb::NotifyTZDataStatusChangeL Exit" );
       
   460 	
   429 	}
   461 	}
   430 
   462 
   431 void CTzLocalizationDb::UpdateTimeZoneAndCityRecordForSystemDataL(RPointerArray<CTzLocalizedTimeZoneRecord>& aFrequentlyUsedZones, 
   463 void CTzLocalizationDb::UpdateTimeZoneAndCityRecordForSystemDataL(RPointerArray<CTzLocalizedTimeZoneRecord>& aFrequentlyUsedZones, 
   432 		RPointerArray<CTzLocalizedCityRecord>& aCachedCities, TInt aTzId, CTzSystemDataDb& aSystemDataDb)
   464 		RPointerArray<CTzLocalizedCityRecord>& aCachedCities, TInt aTzId, CTzSystemDataDb& aSystemDataDb)
   433 	{
   465 	{
   466 */
   498 */
   467 void CTzLocalizationDb::ReadCitiesL(RPointerArray<CTzLocalizedCityRecord>& aCities)
   499 void CTzLocalizationDb::ReadCitiesL(RPointerArray<CTzLocalizedCityRecord>& aCities)
   468 	{
   500 	{
   469 	if (iLocked)
   501 	if (iLocked)
   470 		{
   502 		{
       
   503 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_ERROR, CTZLOCALIZATIONDB_READCITIESL, "CTzLocalizationDb::ReadCitiesL:Database locked" );
       
   504 	    
   471 		User::Leave(KErrLocked);
   505 		User::Leave(KErrLocked);
   472 		}
   506 		}
   473 	_LIT(KSQLQueryLit,"SELECT * FROM UserCities");
   507 	_LIT(KSQLQueryLit,"SELECT * FROM UserCities");
   474 	DoReadCitiesL(aCities,KSQLQueryLit());
   508 	DoReadCitiesL(aCities,KSQLQueryLit());
   475 	}
   509 	}
   476 
   510 
   477 void CTzLocalizationDb::ReadCitiesL(RPointerArray<CTzLocalizedCityRecord>& aCities, TInt aTimeZoneId)
   511 void CTzLocalizationDb::ReadCitiesL(RPointerArray<CTzLocalizedCityRecord>& aCities, TInt aTimeZoneId)
   478 	{
   512 	{
   479 	if (iLocked)
   513 	if (iLocked)
   480 		{
   514 		{
       
   515 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_ERROR, DUP1_CTZLOCALIZATIONDB_READCITIESL, "CTzLocalizationDb::ReadCitiesL:Database locked" );
       
   516 	    
   481 		User::Leave(KErrLocked);
   517 		User::Leave(KErrLocked);
   482 		}
   518 		}
   483 	// Assign basic SQL query literal
   519 	// Assign basic SQL query literal
   484 	_LIT(KSQLQueryLit,"SELECT * FROM UserCities WHERE TzId = ");
   520 	_LIT(KSQLQueryLit,"SELECT * FROM UserCities WHERE TzId = ");
   485 	// Assign a buffer with enough room to hold the query including the time zone id
   521 	// Assign a buffer with enough room to hold the query including the time zone id
   495 
   531 
   496 void CTzLocalizationDb::ReadCitiesInGroupL(RPointerArray<CTzLocalizedCityRecord>& aCities, TUint8 aGroupId)
   532 void CTzLocalizationDb::ReadCitiesInGroupL(RPointerArray<CTzLocalizedCityRecord>& aCities, TUint8 aGroupId)
   497 	{
   533 	{
   498 	if (iLocked)
   534 	if (iLocked)
   499 		{
   535 		{
       
   536 	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_ERROR, CTZLOCALIZATIONDB_READCITIESINGROUPL, "CTzLocalizationDb::ReadCitiesInGroupL:Database locked" );
       
   537 	    
   500 		User::Leave(KErrLocked);
   538 		User::Leave(KErrLocked);
   501 		}
   539 		}
   502 	// Assign basic SQL query literal
   540 	// Assign basic SQL query literal
   503 	_LIT(KSQLQueryLit,"SELECT * FROM UserCities WHERE GroupId = ");
   541 	_LIT(KSQLQueryLit,"SELECT * FROM UserCities WHERE GroupId = ");
   504 	HBufC* sqlStr = HBufC::NewLC(KSQLQueryLit().Length() + EMaxGroupIdStringLength);
   542 	HBufC* sqlStr = HBufC::NewLC(KSQLQueryLit().Length() + EMaxGroupIdStringLength);
   520 */
   558 */
   521 CTzLocalizedTimeZoneRecord* CTzLocalizationDb::ReadFrequentlyUsedZoneL(TInt aFrequentlyUsedZone)
   559 CTzLocalizedTimeZoneRecord* CTzLocalizationDb::ReadFrequentlyUsedZoneL(TInt aFrequentlyUsedZone)
   522 	{
   560 	{
   523 	if (iLocked)
   561 	if (iLocked)
   524 		{
   562 		{
       
   563 	    OstTraceDef1( OST_TRACE_CATEGORY_DEBUG,TRACE_ERROR, CTZLOCALIZATIONDB_READFREQUENTLYUSEDZONEL, "CTzLocalizationDb::ReadFrequentlyUsedZoneL: Database locked;aFrequentlyUsedZone=%d", aFrequentlyUsedZone );
       
   564 	    
   525 		User::Leave(KErrLocked);
   565 		User::Leave(KErrLocked);
   526 		}
   566 		}
   527 	return DoReadFrequentlyUsedZoneL(aFrequentlyUsedZone);
   567 	return DoReadFrequentlyUsedZoneL(aFrequentlyUsedZone);
   528 	}
   568 	}
   529 
   569 
   568 */
   608 */
   569 CTzLocalizedCityRecord* CTzLocalizationDb::ReadCachedTimeZoneCityL(TInt aFrequentlyUsedZone)
   609 CTzLocalizedCityRecord* CTzLocalizationDb::ReadCachedTimeZoneCityL(TInt aFrequentlyUsedZone)
   570 	{
   610 	{
   571 	if (iLocked)
   611 	if (iLocked)
   572 		{
   612 		{
       
   613 	    OstTraceDef1( OST_TRACE_CATEGORY_DEBUG,TRACE_ERROR, CTZLOCALIZATIONDB_READCACHEDTIMEZONECITYL, "CTzLocalizationDb::ReadCachedTimeZoneCityL:Database locked;aFrequentlyUsedZone=%d", aFrequentlyUsedZone );
       
   614 	    
   573 		User::Leave(KErrLocked);
   615 		User::Leave(KErrLocked);
   574 		}
   616 		}
   575 	
   617 	
   576 	// You cannot pass ECachedTimeZones in as the argument, because it is only
   618 	// You cannot pass ECachedTimeZones in as the argument, because it is only
   577 	// used to keep count of how many cached zones there are.
   619 	// used to keep count of how many cached zones there are.
   610 	return city;
   652 	return city;
   611 	}
   653 	}
   612 
   654 
   613 void CTzLocalizationDb::WriteCityL(const TDesC& aCityName, TUint16 aCityTzId, TUint8 aCityGroupId, TUint aCityTzResourceId)
   655 void CTzLocalizationDb::WriteCityL(const TDesC& aCityName, TUint16 aCityTzId, TUint8 aCityGroupId, TUint aCityTzResourceId)
   614 	{
   656 	{
       
   657     OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, DUP2_CTZLOCALIZATIONDB_WRITECITYL_ENTRY, "CTzLocalizationDb::WriteCityL Entry;aCityName=%S;aCityTzId=%hd;aCityGroupId=%hhu;aCityTzResourceId=%u", aCityName, aCityTzId, aCityGroupId, aCityTzResourceId );
       
   658     
   615 	if (iLocked)
   659 	if (iLocked)
   616 		{
   660 		{
       
   661 	       OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_ERROR, CTZLOCALIZATIONDB_WRITECITYL, "CTzLocalizationDb::WriteCityL:Database locked" );
       
   662 	       
   617 		User::Leave(KErrLocked);
   663 		User::Leave(KErrLocked);
   618 		}
   664 		}
   619 	
   665 	
   620 	// Build a SQL query to check if the city name already exists in the database
   666 	// Build a SQL query to check if the city name already exists in the database
   621 	// with a matching timezoneID
   667 	// with a matching timezoneID
   650 		cityView.PutL(); // Complete insertion
   696 		cityView.PutL(); // Complete insertion
   651 		}
   697 		}
   652 	else
   698 	else
   653 		{
   699 		{
   654 		//City already exists.
   700 		//City already exists.
       
   701 	   OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_ERROR, DUP1_CTZLOCALIZATIONDB_WRITECITYL, "CTzLocalizationDb::WriteCityL:City already exists" );
       
   702 	   
   655 		User::Leave(KErrAlreadyExists);
   703 		User::Leave(KErrAlreadyExists);
   656 		}
   704 		}
   657 	CleanupStack::PopAndDestroy(&cityView);
   705 	CleanupStack::PopAndDestroy(&cityView);
   658 	iZoneMutex.Wait();
   706 	iZoneMutex.Wait();
   659 	iLocalizedTimeZoneDb.Compact();
   707 	iLocalizedTimeZoneDb.Compact();
   660 	iZoneMutex.Signal();
   708 	iZoneMutex.Signal();
       
   709 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, DUP2_CTZLOCALIZATIONDB_WRITECITYL_EXIT, "CTzLocalizationDb::WriteCityL Exit" );
       
   710 	
   661 	}
   711 	}
   662 
   712 
   663 void CTzLocalizationDb::DeleteCityL(const TDesC& aCityName, TUint16 aCityTzId)
   713 void CTzLocalizationDb::DeleteCityL(const TDesC& aCityName, TUint16 aCityTzId)
   664 	{
   714 	{
   665 	if (iLocked)
   715 	if (iLocked)
   666 		{
   716 		{
       
   717 	  	    OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_ERROR, CTZLOCALIZATIONDB_DELETECITYL, "CTzLocalizationDb::DeleteCityL:Database locked" );
       
   718 	  	    
   667 		User::Leave(KErrLocked);
   719 		User::Leave(KErrLocked);
   668 		}
   720 		}
   669 	
   721 	
   670 	//Build a SQL query to check if the city name and time zone ID exist in the database
   722 	//Build a SQL query to check if the city name and time zone ID exist in the database
   671 	RDbView cityView;
   723 	RDbView cityView;
   708 @internalTechnology
   760 @internalTechnology
   709 */
   761 */
   710 void CTzLocalizationDb::WriteFrequentlyUsedZoneL(const CTzLocalizedTimeZoneRecord& aTimeZone, 
   762 void CTzLocalizationDb::WriteFrequentlyUsedZoneL(const CTzLocalizedTimeZoneRecord& aTimeZone, 
   711 		const CTzLocalizedCityRecord& aCity, TInt aFrequentlyUsedZone)
   763 		const CTzLocalizedCityRecord& aCity, TInt aFrequentlyUsedZone)
   712 	{
   764 	{
       
   765     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_WRITEFREQUENTLYUSEDZONEL_ENTRY, "CTzLocalizationDb::WriteFrequentlyUsedZoneL Entry" );
       
   766     
       
   767     
   713 	if (iLocked)
   768 	if (iLocked)
   714 		{
   769 		{	   
   715 		User::Leave(KErrLocked);
   770 		User::Leave(KErrLocked);
   716 		}
   771 		}
   717 	
   772 	
   718 	// Only the Current, Home and Zone of Interest can be changed explicitly
   773 	// Only the Current, Home and Zone of Interest can be changed explicitly
   719 	// using this function.  Recent Zones are automatically updated.
   774 	// using this function.  Recent Zones are automatically updated.
   795 	//and shuold be reset to a known state before reusing
   850 	//and shuold be reset to a known state before reusing
   796 	//Cleanup
   851 	//Cleanup
   797 	CleanupStack::PopAndDestroy(&zoneView);
   852 	CleanupStack::PopAndDestroy(&zoneView);
   798 	iLocalizedTimeZoneDb.Compact();
   853 	iLocalizedTimeZoneDb.Compact();
   799 	iZoneMutex.Signal();
   854 	iZoneMutex.Signal();
       
   855 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_WRITEFREQUENTLYUSEDZONEL_EXIT, "CTzLocalizationDb::WriteFrequentlyUsedZoneL Exit" );
       
   856 	
   800 	}
   857 	}
   801 
   858 
   802 /**
   859 /**
   803 Sets all the cached zones and their associated cities to be those that are
   860 Sets all the cached zones and their associated cities to be those that are
   804 supplied.
   861 supplied.
   809 void CTzLocalizationDb::WriteAllFrequentlyUsedZonesL(const RPointerArray<CTzLocalizedTimeZoneRecord>& aTimeZones, 
   866 void CTzLocalizationDb::WriteAllFrequentlyUsedZonesL(const RPointerArray<CTzLocalizedTimeZoneRecord>& aTimeZones, 
   810 		const RPointerArray<CTzLocalizedCityRecord>& aCities)
   867 		const RPointerArray<CTzLocalizedCityRecord>& aCities)
   811 	{
   868 	{
   812 	if (iLocked)
   869 	if (iLocked)
   813 		{
   870 		{
       
   871 	 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_ERROR, CTZLOCALIZATIONDB_WRITEALLFREQUENTLYUSEDZONESL, "CTzLocalizationDb::WriteAllFrequentlyUsedZonesL:Database locked" );
       
   872 	 
   814 		User::Leave(KErrLocked);
   873 		User::Leave(KErrLocked);
   815 		}
   874 		}
   816 	DoWriteAllFrequentlyUsedZonesL(aTimeZones, aCities);
   875 	DoWriteAllFrequentlyUsedZonesL(aTimeZones, aCities);
   817 	}
   876 	}
   818 
   877 
  1006 	return timeZoneIdInt;
  1065 	return timeZoneIdInt;
  1007 	}
  1066 	}
  1008 
  1067 
  1009 void CTzLocalizationDb::NotifyUserTzNamesChangeL(TTzUserDataChange aChange)
  1068 void CTzLocalizationDb::NotifyUserTzNamesChangeL(TTzUserDataChange aChange)
  1010 	{
  1069 	{
       
  1070     OstTraceDefExt2( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYUSERTZNAMESCHANGEL_ENTRY, "CTzLocalizationDb::NotifyUserTzNamesChangeL Entry;Operation=%u;Time zone Id=%d",aChange.iOperation, aChange.iTzId );
       
  1071     
  1011 	// If an existing user-defined time zone is updated it means we may have
  1072 	// If an existing user-defined time zone is updated it means we may have
  1012 	// to refresh the data in the frequently used zones table but the city table
  1073 	// to refresh the data in the frequently used zones table but the city table
  1013 	// only contains the time zone id so there is nothing to update in there.
  1074 	// only contains the time zone id so there is nothing to update in there.
  1014 	
  1075 	
  1015 	// If an existing user-defined time zone is deleted it means we may have
  1076 	// If an existing user-defined time zone is deleted it means we may have
  1094 		iZoneMutex.Signal();
  1155 		iZoneMutex.Signal();
  1095 		}
  1156 		}
  1096 	CleanupStack::PopAndDestroy(&cachedCities); 
  1157 	CleanupStack::PopAndDestroy(&cachedCities); 
  1097 	CleanupStack::PopAndDestroy(&frequentlyUsedZones);
  1158 	CleanupStack::PopAndDestroy(&frequentlyUsedZones);
  1098 	CleanupStack::PopAndDestroy(systemDataDb);
  1159 	CleanupStack::PopAndDestroy(systemDataDb);
       
  1160 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_NOTIFYUSERTZNAMESCHANGEL_EXIT, "CTzLocalizationDb::NotifyUserTzNamesChangeL Exit" );
       
  1161 	
  1099 	}
  1162 	}
  1100 
  1163 
  1101 void CTzLocalizationDb::UpdateTimeZoneAndCityRecordL(RPointerArray<CTzLocalizedTimeZoneRecord>& aFrequentlyUsedZones, RPointerArray<CTzLocalizedCityRecord>& aCachedCities, TInt aTzId)
  1164 void CTzLocalizationDb::UpdateTimeZoneAndCityRecordL(RPointerArray<CTzLocalizedTimeZoneRecord>& aFrequentlyUsedZones, RPointerArray<CTzLocalizedCityRecord>& aCachedCities, TInt aTzId)
  1102 	{
  1165 	{
  1103 	CTzUserNames* names = iServer.UserTimeZoneDb().ReadTzNamesL(aTzId);
  1166 	CTzUserNames* names = iServer.UserTimeZoneDb().ReadTzNamesL(aTzId);
  1186 	iLocked = ETrue;
  1249 	iLocked = ETrue;
  1187 	}
  1250 	}
  1188 
  1251 
  1189 void CTzLocalizationDb::RestoreDbL()
  1252 void CTzLocalizationDb::RestoreDbL()
  1190 	{
  1253 	{
       
  1254     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_RESTOREDBL_ENTRY, "CTzLocalizationDb::RestoreDbL Entry" );
       
  1255     
  1191 	// When the Tz server is connected or a restore completes, we have to
  1256 	// When the Tz server is connected or a restore completes, we have to
  1192 	// refresh the data in the frequently used zones table and the city table
  1257 	// refresh the data in the frequently used zones table and the city table
  1193 	// because it may contain the time zone id that has been deleted.  Or if the
  1258 	// because it may contain the time zone id that has been deleted.  Or if the
  1194 	// time zone id is still there but the details of the rule has been changed.
  1259 	// time zone id is still there but the details of the rule has been changed.
  1195 
  1260 
  1248 	DeleteCitiesL(change);
  1313 	DeleteCitiesL(change);
  1249 	
  1314 	
  1250 	CleanupStack::PopAndDestroy(&cachedCities); 
  1315 	CleanupStack::PopAndDestroy(&cachedCities); 
  1251 	CleanupStack::PopAndDestroy(&frequentlyUsedZones);
  1316 	CleanupStack::PopAndDestroy(&frequentlyUsedZones);
  1252 	CleanupStack::PopAndDestroy(systemDataDb);
  1317 	CleanupStack::PopAndDestroy(systemDataDb);
       
  1318 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZLOCALIZATIONDB_RESTOREDBL_EXIT, "CTzLocalizationDb::RestoreDbL Exit" );
       
  1319 	
  1253 	}
  1320 	}
  1254 
  1321 
  1255 /**
  1322 /**
  1256 Get the localized default time zone Id for the given frequently used time zone.
  1323 Get the localized default time zone Id for the given frequently used time zone.
  1257 The default time zone for each of the possible frequently used time zones may be
  1324 The default time zone for each of the possible frequently used time zones may be