clock/clockmw/clocktimezone/src/timezoneclient.cpp
changeset 58 ef813d54df51
parent 50 579cc610882e
equal deleted inserted replaced
50:579cc610882e 58:ef813d54df51
    30 // User includes
    30 // User includes
    31 #include "timezoneclient.h"
    31 #include "timezoneclient.h"
    32 #include "clockcommon.h"
    32 #include "clockcommon.h"
    33 #include "clockserverclt.h"
    33 #include "clockserverclt.h"
    34 #include "clockprivatecrkeys.h"
    34 #include "clockprivatecrkeys.h"
       
    35 #include "environmentchangenotifier.h"
       
    36 #include "OstTraceDefinitions.h"
       
    37 #ifdef OST_TRACE_COMPILER_IN_USE
       
    38 #include "timezoneclientTraces.h"
       
    39 #endif
       
    40 
    35 
    41 
    36 const int KDaysInWeek(7);
    42 const int KDaysInWeek(7);
    37 const int KZerothRule(0);
    43 const int KZerothRule(0);
    38 const int KOneHour(1);
    44 const int KOneHour(1);
    39 const int KNoDifference(0);
    45 const int KNoDifference(0);
    50 /*!
    56 /*!
    51 	Call this funtion to instantiate the TimezoneClient class.
    57 	Call this funtion to instantiate the TimezoneClient class.
    52  */
    58  */
    53 TimezoneClient* TimezoneClient::getInstance()
    59 TimezoneClient* TimezoneClient::getInstance()
    54 {
    60 {
       
    61 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETINSTANCE_ENTRY );
    55 	if (!mTimezoneClient) {
    62 	if (!mTimezoneClient) {
    56 		mTimezoneClient = new TimezoneClient();
    63 		mTimezoneClient = new TimezoneClient();
    57 		mReferenceCount = true;
    64 		mReferenceCount = true;
    58 	}
    65 	}
    59 
    66 
       
    67 	OstTraceFunctionExit0( TIMEZONECLIENT_GETINSTANCE_EXIT );
    60 	return mTimezoneClient;
    68 	return mTimezoneClient;
    61 }
    69 }
    62 
    70 
    63 /*!
    71 /*!
    64 	Call this function to clean up the instance of TimezoneClient class.
    72 	Call this function to clean up the instance of TimezoneClient class.
    65  */
    73  */
    66 void TimezoneClient::deleteInstance()
    74 void TimezoneClient::deleteInstance()
    67 {
    75 {
       
    76 	OstTraceFunctionEntry0( TIMEZONECLIENT_DELETEINSTANCE_ENTRY );
    68 	if (mReferenceCount) {
    77 	if (mReferenceCount) {
    69 		delete mTimezoneClient;
    78 		delete mTimezoneClient;
    70 		mTimezoneClient = 0;
    79 		mTimezoneClient = 0;
    71 	}
    80 		mReferenceCount = false;
       
    81 	}
       
    82 	OstTraceFunctionExit0( TIMEZONECLIENT_DELETEINSTANCE_EXIT );
    72 }
    83 }
    73 
    84 
    74 /*!
    85 /*!
    75 	Call this function to check if the object is NULL.
    86 	Call this function to check if the object is NULL.
    76  */
    87  */
    77 bool TimezoneClient::isNull()
    88 bool TimezoneClient::isNull()
    78 {
    89 {
       
    90 	OstTraceFunctionEntry0( TIMEZONECLIENT_ISNULL_ENTRY );
       
    91 	OstTraceFunctionExit0( TIMEZONECLIENT_ISNULL_EXIT );
    79 	return !mReferenceCount;
    92 	return !mReferenceCount;
    80 }
    93 }
    81 
    94 
    82 /*!
    95 /*!
    83 	The constructor.
    96 	The constructor.
    84  */
    97  */
    85 TimezoneClient::TimezoneClient()
    98 TimezoneClient::TimezoneClient()
    86 {
    99 {	
    87 	TCallBack callback(environmentCallback, this);
   100 	OstTraceFunctionEntry0( TIMEZONECLIENT_TIMEZONECLIENT_ENTRY );
    88 
   101 	mNotifier = new EnvironmentChangeNotifier(this);
    89 	mNotifier = CEnvironmentChangeNotifier::NewL(
       
    90 			CActive::EPriorityStandard, callback);
       
    91 	mNotifier->Start();
       
    92 
   102 
    93 	mTzLocalizer = CTzLocalizer::NewL();
   103 	mTzLocalizer = CTzLocalizer::NewL();
    94 
   104 
    95 	// Create the settings manager.
   105 	// Create the settings manager.
    96 	mSettingsManager = new XQSettingsManager(this);
   106 	mSettingsManager = new XQSettingsManager(this);
   109 
   119 
   110 	// Listen to the key value changes.
   120 	// Listen to the key value changes.
   111 	connect(
   121 	connect(
   112 			mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
   122 			mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
   113 			this, SLOT(eventMonitor(XQSettingsKey, QVariant)));
   123 			this, SLOT(eventMonitor(XQSettingsKey, QVariant)));
       
   124 	OstTraceFunctionExit0( TIMEZONECLIENT_TIMEZONECLIENT_EXIT );
   114 }
   125 }
   115 
   126 
   116 /*!
   127 /*!
   117 	Destructor.
   128 	Destructor.
   118  */
   129  */
   119 TimezoneClient::~TimezoneClient()
   130 TimezoneClient::~TimezoneClient()
   120 {
   131 {
       
   132 	OstTraceFunctionEntry0( DUP1_TIMEZONECLIENT_TIMEZONECLIENT_ENTRY );
   121 	if (mNotifier) {
   133 	if (mNotifier) {
   122 		mNotifier->Cancel();
       
   123 		delete mNotifier;
   134 		delete mNotifier;
   124 		mNotifier = 0;
       
   125 	}
   135 	}
   126 	if (mWorldClockModel) {
   136 	if (mWorldClockModel) {
   127 		mWorldClockModel->clear();
   137 		mWorldClockModel->clear();
   128 	}
   138 	}
   129 	if (mTzLocalizer) {
   139 	if (mTzLocalizer) {
   135 	}
   145 	}
   136 	// Clear the locations if exist.
   146 	// Clear the locations if exist.
   137 	if (mAllLocations.count()) {
   147 	if (mAllLocations.count()) {
   138 		mAllLocations.clear();
   148 		mAllLocations.clear();
   139 	}
   149 	}
   140 
   150 	OstTraceFunctionExit0( DUP1_TIMEZONECLIENT_TIMEZONECLIENT_EXIT );
   141 }
   151 }
   142 
   152 
   143 /*!
   153 /*!
   144 	This functions returns a QList of location info which represent all the
   154 	This functions returns a QList of location info which represent all the
   145 	cities preset in the device returned by the tz server.
   155 	cities preset in the device returned by the tz server.
   148 			valid cityName, countryName, tz id and city group id. None of the other
   158 			valid cityName, countryName, tz id and city group id. None of the other
   149 			data is filled.
   159 			data is filled.
   150  */
   160  */
   151 QList<LocationInfo>& TimezoneClient::getLocations()
   161 QList<LocationInfo>& TimezoneClient::getLocations()
   152 {
   162 {
       
   163 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETLOCATIONS_ENTRY );
   153 	if (mAllLocations.count()) {
   164 	if (mAllLocations.count()) {
   154 		mAllLocations.clear();
   165 		mAllLocations.clear();
   155 	}
   166 	}
   156 
   167 
   157 	// Get the cities, in alphabetical-ascending sorted order.
   168 	// Get the cities, in alphabetical-ascending sorted order.
   199 		mAllLocations.append(cityInfo);
   210 		mAllLocations.append(cityInfo);
   200 	}
   211 	}
   201 
   212 
   202 	// Cleanup.
   213 	// Cleanup.
   203 	CleanupStack::PopAndDestroy(cityArray);
   214 	CleanupStack::PopAndDestroy(cityArray);
       
   215 	OstTraceFunctionExit0( TIMEZONECLIENT_GETLOCATIONS_EXIT );
   204 	return mAllLocations;
   216 	return mAllLocations;
   205 }
   217 }
   206 
   218 
   207 bool TimezoneClient::getUtcDstOffsetL(int& dstOffset, const CTzId& timezoneId)
   219 bool TimezoneClient::getUtcDstOffsetL(int& dstOffset, const CTzId& timezoneId)
   208 {
   220 {
       
   221 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETUTCDSTOFFSETL_ENTRY );
   209 	RTz tzHandle;
   222 	RTz tzHandle;
   210 	User::LeaveIfError(tzHandle.Connect());
   223 	User::LeaveIfError(tzHandle.Connect());
   211 	CleanupClosePushL(tzHandle);
   224 	CleanupClosePushL(tzHandle);
   212 
   225 
   213 	// Local time.
   226 	// Local time.
   261 		if (initialTimeZoneOffset != tVTzactRule.iNewOffset) {
   274 		if (initialTimeZoneOffset != tVTzactRule.iNewOffset) {
   262 			dstOffset = tVTzactRule.iNewOffset;
   275 			dstOffset = tVTzactRule.iNewOffset;
   263 			CleanupStack::PopAndDestroy(actualizedRules);
   276 			CleanupStack::PopAndDestroy(actualizedRules);
   264 			CleanupStack::PopAndDestroy(timezoneRules);
   277 			CleanupStack::PopAndDestroy(timezoneRules);
   265 			CleanupStack::PopAndDestroy(&tzHandle);
   278 			CleanupStack::PopAndDestroy(&tzHandle);
       
   279 			OstTraceFunctionExit0( TIMEZONECLIENT_GETUTCDSTOFFSETL_EXIT );
   266 			return true;
   280 			return true;
   267 		} else {
   281 		} else {
   268 			dstOffset = initialTimeZoneOffset;
   282 			dstOffset = initialTimeZoneOffset;
   269 		}
   283 		}
   270 	}
   284 	}
   271 	CleanupStack::PopAndDestroy(actualizedRules);
   285 	CleanupStack::PopAndDestroy(actualizedRules);
   272 	CleanupStack::PopAndDestroy(timezoneRules);
   286 	CleanupStack::PopAndDestroy(timezoneRules);
   273 	CleanupStack::PopAndDestroy(&tzHandle);
   287 	CleanupStack::PopAndDestroy(&tzHandle);
       
   288 	OstTraceFunctionExit0( DUP1_TIMEZONECLIENT_GETUTCDSTOFFSETL_EXIT );
   274 	return false;
   289 	return false;
   275 }
   290 }
   276 
   291 
   277 LocationInfo TimezoneClient::getCurrentZoneInfoL()
   292 LocationInfo TimezoneClient::getCurrentZoneInfoL()
   278 {
   293 {
       
   294 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETCURRENTZONEINFOL_ENTRY );
   279 	// Current zone info.
   295 	// Current zone info.
   280 	LocationInfo currentLocation;
   296 	LocationInfo currentLocation;
   281 	int timezoneId(0);
   297 	int timezoneId(0);
   282 	int utcOffset(0);
   298 	int utcOffset(0);
   283 
   299 
   400 	}
   416 	}
   401 
   417 
   402 	// Cleanup.
   418 	// Cleanup.
   403 	CleanupStack::PopAndDestroy( tzId );
   419 	CleanupStack::PopAndDestroy( tzId );
   404 	CleanupStack::PopAndDestroy( &tzHandle );
   420 	CleanupStack::PopAndDestroy( &tzHandle );
       
   421 	OstTraceFunctionExit0( TIMEZONECLIENT_GETCURRENTZONEINFOL_EXIT );
   405 	return currentLocation;
   422 	return currentLocation;
   406 }
   423 }
   407 
   424 
   408 void TimezoneClient::setAsCurrentLocationL(LocationInfo &location)
   425 void TimezoneClient::setAsCurrentLocationL(LocationInfo &location)
   409 {
   426 {
   410 /*	Debug::writeDebugMsg(
   427 	OstTraceFunctionEntry0( TIMEZONECLIENT_SETASCURRENTLOCATIONL_ENTRY );
   411 			"In time zone client setAsCurrentLocationL " + location.cityName +
       
   412 			" " +
       
   413 			location.countryName +
       
   414 			" " +
       
   415 			QString::number(location.zoneOffset));*/
       
   416 
       
   417 	LocationInfo prevLocationInfo ;
   428 	LocationInfo prevLocationInfo ;
   418 	prevLocationInfo = getCurrentZoneInfoL();
   429 	prevLocationInfo = getCurrentZoneInfoL();
   419 
   430 	QTime prevLocationTime = QTime::currentTime();
       
   431 	
   420 	mTzLocalizer->SetTimeZoneL( location.timezoneId );
   432 	mTzLocalizer->SetTimeZoneL( location.timezoneId );
   421 
   433 
   422 	TPtrC ptrCityName(
   434 	TPtrC ptrCityName(
   423 			reinterpret_cast<const TText*>(location.cityName.constData()));
   435 			reinterpret_cast<const TText*>(location.cityName.constData()));
   424 	CTzLocalizedCity* localizedCity =
   436 	CTzLocalizedCity* localizedCity =
   431 	CleanupStack::PopAndDestroy( localizedCity );
   443 	CleanupStack::PopAndDestroy( localizedCity );
   432 
   444 
   433 	if(prevLocationInfo.timezoneId == location.timezoneId) {
   445 	if(prevLocationInfo.timezoneId == location.timezoneId) {
   434 		emit cityUpdated();	
   446 		emit cityUpdated();	
   435 	}
   447 	}
       
   448 	
       
   449 	QTime newTime = QTime::currentTime();	
       
   450 	if ((prevLocationTime.hour() == newTime.hour())
       
   451 			&& (prevLocationTime.minute() == newTime.minute())
       
   452 			&& (prevLocationInfo.timezoneId != location.timezoneId)) {
       
   453 	    emit cityUpdated();
       
   454     }
       
   455 	OstTraceFunctionExit0( TIMEZONECLIENT_SETASCURRENTLOCATIONL_EXIT );
   436 }
   456 }
   437 
   457 
   438 bool TimezoneClient::isDSTOnL(int timezoneId)
   458 bool TimezoneClient::isDSTOnL(int timezoneId)
   439 {
   459 {
       
   460 	OstTraceFunctionEntry0( TIMEZONECLIENT_ISDSTONL_ENTRY );
   440 	bool returnVal( false );
   461 	bool returnVal( false );
   441 	CTzId* tzId = CTzId::NewL( timezoneId );
   462 	CTzId* tzId = CTzId::NewL( timezoneId );
   442 	CleanupStack::PushL( tzId );
   463 	CleanupStack::PushL( tzId );
   443 
   464 
   444 	RTz tzHandle;
   465 	RTz tzHandle;
   449 
   470 
   450 	tzHandle.Close();
   471 	tzHandle.Close();
   451 	CleanupStack::PopAndDestroy( &tzHandle );
   472 	CleanupStack::PopAndDestroy( &tzHandle );
   452 	CleanupStack::PopAndDestroy( tzId );
   473 	CleanupStack::PopAndDestroy( tzId );
   453 
   474 
       
   475 	OstTraceFunctionExit0( TIMEZONECLIENT_ISDSTONL_EXIT );
   454 	return returnVal;
   476 	return returnVal;
   455 }
   477 }
   456 
   478 
   457 int TimezoneClient::getStandardOffset(int timezoneId)
   479 int TimezoneClient::getStandardOffset(int timezoneId)
   458 {
   480 {
       
   481 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETSTANDARDOFFSET_ENTRY );
   459 	RTz tzHandle;
   482 	RTz tzHandle;
   460 	User::LeaveIfError(tzHandle.Connect());
   483 	User::LeaveIfError(tzHandle.Connect());
   461 	CleanupClosePushL(tzHandle);
   484 	CleanupClosePushL(tzHandle);
   462 
   485 
   463 	RArray<int> idArray;
   486 	RArray<int> idArray;
   464 	RArray<int> offsetArray;
   487 	RArray<int> offsetArray;
   465 	idArray.Append(timezoneId);
   488 	idArray.Append(timezoneId);
   466 
   489 
   467 	tzHandle.GetOffsetsForTimeZoneIdsL(idArray, offsetArray);
   490 	tzHandle.GetOffsetsForTimeZoneIdsL(idArray, offsetArray);
   468 	int stdOffset = offsetArray[0];
   491 	int stdOffset = offsetArray[0];
       
   492 	
       
   493 	if (isDSTOnL(timezoneId)) {
       
   494 		CTzId* tzId = CTzId::NewL( timezoneId );
       
   495 		CleanupStack::PushL( tzId );
       
   496 		
       
   497 		// Get the offset with DST enabled.
       
   498 		getUtcDstOffsetL(stdOffset, *tzId);
       
   499 		
       
   500 		CleanupStack::PopAndDestroy(tzId);
       
   501 		
       
   502     }
   469 
   503 
   470 	offsetArray.Close();
   504 	offsetArray.Close();
   471 	idArray.Close();
   505 	idArray.Close();
   472 
   506 
   473 	// Cleanup.
   507 	// Cleanup.
   474 	CleanupStack::PopAndDestroy(&tzHandle);
   508 	CleanupStack::PopAndDestroy(&tzHandle);
   475 
   509 
       
   510 	OstTraceFunctionExit0( TIMEZONECLIENT_GETSTANDARDOFFSET_EXIT );
   476 	return stdOffset;
   511 	return stdOffset;
   477 }
   512 }
   478 
   513 
   479 void TimezoneClient::getDstRulesL(
   514 void TimezoneClient::getDstRulesL(
   480 		QDateTime &startTime, QDateTime &endTime, int timezoneId)
   515 		QDateTime &startTime, QDateTime &endTime, int timezoneId)
   481 {
   516 {
       
   517 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETDSTRULESL_ENTRY );
   482 	RTz tzHandle;
   518 	RTz tzHandle;
   483 	User::LeaveIfError(tzHandle.Connect());
   519 	User::LeaveIfError(tzHandle.Connect());
   484 	CleanupClosePushL(tzHandle);
   520 	CleanupClosePushL(tzHandle);
   485 
   521 
   486 	// Local time.
   522 	// Local time.
   564 	}
   600 	}
   565 	CleanupStack::PopAndDestroy(actualizedRules);
   601 	CleanupStack::PopAndDestroy(actualizedRules);
   566 	CleanupStack::PopAndDestroy(timezoneRules);
   602 	CleanupStack::PopAndDestroy(timezoneRules);
   567 	CleanupStack::PopAndDestroy(tzId);
   603 	CleanupStack::PopAndDestroy(tzId);
   568 	CleanupStack::PopAndDestroy(&tzHandle);
   604 	CleanupStack::PopAndDestroy(&tzHandle);
       
   605 OstTraceFunctionExit0( TIMEZONECLIENT_GETDSTRULESL_EXIT );
   569 }
   606 }
   570 
   607 
   571 QList<LocationInfo> TimezoneClient::getSavedLocations()
   608 QList<LocationInfo> TimezoneClient::getSavedLocations()
   572 {
   609 {
       
   610 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETSAVEDLOCATIONS_ENTRY );
   573 	QList<LocationInfo> locationList;
   611 	QList<LocationInfo> locationList;
   574 
   612 
   575 	QString fileName(CITY_INFO_DB_PATH);
   613 	QString fileName(CITY_INFO_DB_PATH);
   576 	fileName.append(CITY_INFO_DB);
   614 	fileName.append(CITY_INFO_DB);
   577 
   615 
   579 	if (cityInfoFile.open(QIODevice::ReadOnly)) {
   617 	if (cityInfoFile.open(QIODevice::ReadOnly)) {
   580 		QDataStream writeStream(&cityInfoFile);
   618 		QDataStream writeStream(&cityInfoFile);
   581 		writeStream >> locationList;
   619 		writeStream >> locationList;
   582 		cityInfoFile.close();
   620 		cityInfoFile.close();
   583 	}
   621 	}
       
   622 	OstTraceFunctionExit0( TIMEZONECLIENT_GETSAVEDLOCATIONS_EXIT );
   584 	return locationList;
   623 	return locationList;
   585 }
   624 }
   586 
   625 
   587 void TimezoneClient::saveLocations(const QList<LocationInfo> &locationList)
   626 void TimezoneClient::saveLocations(const QList<LocationInfo> &locationList)
   588 {
   627 {
       
   628 	OstTraceFunctionEntry0( TIMEZONECLIENT_SAVELOCATIONS_ENTRY );
   589 	QDir cityDbDir;
   629 	QDir cityDbDir;
   590 	cityDbDir.mkpath(CITY_INFO_DB_PATH);
   630 	cityDbDir.mkpath(CITY_INFO_DB_PATH);
   591 
   631 
   592 	QString fileName(CITY_INFO_DB_PATH);
   632 	QString fileName(CITY_INFO_DB_PATH);
   593 	fileName.append(CITY_INFO_DB);
   633 	fileName.append(CITY_INFO_DB);
   594 
   634 
   595 	QFile cityInfoFile(fileName);
   635 	QFile cityInfoFile(fileName);
   596 	if (!cityInfoFile.open(QIODevice::WriteOnly)) {
   636 	if (!cityInfoFile.open(QIODevice::WriteOnly)) {
   597 		// Error opening or creating file.
   637 		// Error opening or creating file.
       
   638 		OstTraceFunctionExit0( TIMEZONECLIENT_SAVELOCATIONS_EXIT );
   598 		return;
   639 		return;
   599 	}
   640 	}
   600 	QDataStream writeStream(&cityInfoFile);
   641 	QDataStream writeStream(&cityInfoFile);
   601 	writeStream << locationList;
   642 	writeStream << locationList;
   602 	cityInfoFile.close();
   643 	cityInfoFile.close();
   603 
   644 
   604 	emit listUpdated();
   645 	emit listUpdated();
   605 }
   646 OstTraceFunctionExit0( DUP1_TIMEZONECLIENT_SAVELOCATIONS_EXIT );
   606 
       
   607 void TimezoneClient::getCountries(QMap<QString, int>& countries)
       
   608 {
       
   609 	// Get all the city groups(countries).
       
   610 	QTime t;
       
   611 	t.start();
       
   612 	CTzLocalizedCityGroupArray* cityGroupArray =
       
   613 			mTzLocalizer->GetAllCityGroupsL(CTzLocalizer::ETzAlphaNameAscending);
       
   614 	CleanupStack::PushL(cityGroupArray);
       
   615 
       
   616 	t.restart();
       
   617 	// Iterate through each of the city groups.
       
   618 	for (int i = 0; i < cityGroupArray->Count(); i++) {
       
   619 		CTzLocalizedCityGroup& cityGroup(cityGroupArray->At(i));
       
   620 		TPtrC countryName(cityGroup.Name());
       
   621 
       
   622 		// Get the QString of country name
       
   623 		QString qCountryName = QString::fromUtf16(
       
   624 				countryName.Ptr(),countryName.Length());
       
   625 	    countries[qCountryName] = cityGroup.Id();
       
   626 	}
       
   627 
       
   628 	// Cleanup.
       
   629 	CleanupStack::PopAndDestroy(cityGroupArray);
       
   630 }
   647 }
   631 
   648 
   632 void TimezoneClient::getCitiesForCountry(int id, QMap<QString, int>& cities)
   649 void TimezoneClient::getCitiesForCountry(int id, QMap<QString, int>& cities)
   633 {
   650 {
       
   651 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETCITIESFORCOUNTRY_ENTRY );
   634 	// Get the city group for the given id.
   652 	// Get the city group for the given id.
   635 	CTzLocalizedCityArray* cityArray = mTzLocalizer->GetCitiesInGroupL(id,
   653 	CTzLocalizedCityArray* cityArray = mTzLocalizer->GetCitiesInGroupL(id,
   636 			CTzLocalizer::ETzAlphaNameAscending);
   654 			CTzLocalizer::ETzAlphaNameAscending);
   637 	CleanupStack::PushL(cityArray);
   655 	CleanupStack::PushL(cityArray);
   638 	CTzLocalizedCityArray* unsortedArray = mTzLocalizer->GetCitiesInGroupL(id,
   656 	CTzLocalizedCityArray* unsortedArray = mTzLocalizer->GetCitiesInGroupL(id,
   656 	}
   674 	}
   657 
   675 
   658 	// Cleanup.
   676 	// Cleanup.
   659 	CleanupStack::PopAndDestroy(unsortedArray);
   677 	CleanupStack::PopAndDestroy(unsortedArray);
   660 	CleanupStack::PopAndDestroy(cityArray);
   678 	CleanupStack::PopAndDestroy(cityArray);
       
   679 OstTraceFunctionExit0( TIMEZONECLIENT_GETCITIESFORCOUNTRY_EXIT );
   661 }
   680 }
   662 
   681 
   663 void TimezoneClient::getLocationInfo(
   682 void TimezoneClient::getLocationInfo(
   664 		int groupId, int cityIndex, LocationInfo& cityInfo)
   683 		int groupId, int cityIndex, LocationInfo& cityInfo)
   665 {
   684 {
       
   685 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETLOCATIONINFO_ENTRY );
   666 	TRAPD(
   686 	TRAPD(
   667 			error,
   687 			error,
   668 
   688 
   669 			// Get the localized city group.
   689 			// Get the localized city group.
   670 			CTzLocalizedCityGroup* cityGroup = mTzLocalizer->GetCityGroupL(groupId);
   690 			CTzLocalizedCityGroup* cityGroup = mTzLocalizer->GetCityGroupL(groupId);
   690 			// Cleanup.
   710 			// Cleanup.
   691 			CleanupStack::PopAndDestroy(cityArray);
   711 			CleanupStack::PopAndDestroy(cityArray);
   692 			CleanupStack::PopAndDestroy(cityGroup);
   712 			CleanupStack::PopAndDestroy(cityGroup);
   693 	)
   713 	)
   694 	Q_UNUSED(error)
   714 	Q_UNUSED(error)
       
   715 OstTraceFunctionExit0( TIMEZONECLIENT_GETLOCATIONINFO_EXIT );
   695 }
   716 }
   696 
   717 
   697 QDataStream &operator<<(
   718 QDataStream &operator<<(
   698 		QDataStream &writeStream, const LocationInfo& locationInfo)
   719 		QDataStream &writeStream, const LocationInfo& locationInfo)
   699 {
   720 {
       
   721 	OstTraceFunctionEntry0( _OPERATOR_ENTRY );
   700 	writeStream << locationInfo.cityName
   722 	writeStream << locationInfo.cityName
   701 			<< locationInfo.countryName
   723 			<< locationInfo.countryName
   702 			<< locationInfo.listImageName
   724 			<< locationInfo.listImageName
   703 			<< locationInfo.dstOn
   725 			<< locationInfo.dstOn
   704 			<< locationInfo.timezoneId
   726 			<< locationInfo.timezoneId
   705 			<< locationInfo.zoneOffset;
   727 			<< locationInfo.zoneOffset;
       
   728 	OstTraceFunctionExit0( _OPERATOR_EXIT );
   706 	return writeStream;
   729 	return writeStream;
   707 }
   730 }
   708 
   731 
   709 QDataStream &operator>>(
   732 QDataStream &operator>>(
   710 		QDataStream &readStream, LocationInfo &locationInfo)
   733 		QDataStream &readStream, LocationInfo &locationInfo)
   711 {
   734 {
       
   735 	OstTraceFunctionEntry0( DUP1__OPERATOR_ENTRY );
   712 	readStream >> locationInfo.cityName
   736 	readStream >> locationInfo.cityName
   713 	>> locationInfo.countryName
   737 	>> locationInfo.countryName
   714 	>> locationInfo.listImageName
   738 	>> locationInfo.listImageName
   715 	>> locationInfo.dstOn
   739 	>> locationInfo.dstOn
   716 	>> locationInfo.timezoneId
   740 	>> locationInfo.timezoneId
   717 	>> locationInfo.zoneOffset;
   741 	>> locationInfo.zoneOffset;
       
   742 	OstTraceFunctionExit0( DUP1__OPERATOR_EXIT );
   718 	return readStream;
   743 	return readStream;
   719 }
   744 }
   720 
   745 
   721 int TimezoneClient::environmentCallback(TAny* obj)
       
   722 {
       
   723 	TimezoneClient* self = static_cast<TimezoneClient *> (obj);
       
   724 
       
   725 	int changes = KInitialEvent;
       
   726 	if (self->mNotifier) {
       
   727 		changes = self->mNotifier->Change();
       
   728 	}
       
   729 
       
   730 	if (KInitialEvent <= changes) {
       
   731 		// We're not concerned about handling environment changes in that range.
       
   732 		return 0;
       
   733 	}
       
   734 
       
   735 	if (changes & (EChangesMidnightCrossover |
       
   736 			EChangesLocale |
       
   737 			EChangesSystemTime)) {
       
   738 		emit self->timechanged();
       
   739 	} else {
       
   740 		// Nothing to do.
       
   741 	}
       
   742 	return 0;
       
   743 }
       
   744 
       
   745 int TimezoneClient::getDstZoneOffset(int tzId)
   746 int TimezoneClient::getDstZoneOffset(int tzId)
   746 {
   747 {
       
   748 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETDSTZONEOFFSET_ENTRY );
   747 	// Connect to the timezone server.
   749 	// Connect to the timezone server.
   748 	RTz client;
   750 	RTz client;
   749 	User::LeaveIfError(client.Connect());
   751 	User::LeaveIfError(client.Connect());
   750 	CleanupClosePushL(client);
   752 	CleanupClosePushL(client);
   751 
   753 
   757 	client.GetOffsetsForTimeZoneIdsL(zoneIds, zoneOffsets);
   759 	client.GetOffsetsForTimeZoneIdsL(zoneIds, zoneOffsets);
   758 
   760 
   759 	// Cleanup.
   761 	// Cleanup.
   760 	CleanupStack::PopAndDestroy(&client);
   762 	CleanupStack::PopAndDestroy(&client);
   761 
   763 
       
   764 	OstTraceFunctionExit0( TIMEZONECLIENT_GETDSTZONEOFFSET_EXIT );
   762 	return zoneOffsets[0];
   765 	return zoneOffsets[0];
   763 }
   766 }
   764 
   767 
   765 bool TimezoneClient::dstOn(int tzId)
   768 bool TimezoneClient::dstOn(int tzId)
   766 {
   769 {
       
   770 	OstTraceFunctionEntry0( TIMEZONECLIENT_DSTON_ENTRY );
   767 	// Connect to the timezone server.
   771 	// Connect to the timezone server.
   768 	RTz client;
   772 	RTz client;
   769 	User::LeaveIfError(client.Connect());
   773 	User::LeaveIfError(client.Connect());
   770 	CleanupClosePushL(client);
   774 	CleanupClosePushL(client);
   771 
   775 
   776 
   780 
   777 	// Cleanup.
   781 	// Cleanup.
   778 	CleanupStack::PopAndDestroy(zoneId);
   782 	CleanupStack::PopAndDestroy(zoneId);
   779 	CleanupStack::PopAndDestroy(&client);
   783 	CleanupStack::PopAndDestroy(&client);
   780 
   784 
       
   785 	OstTraceFunctionExit0( TIMEZONECLIENT_DSTON_EXIT );
   781 	return returnVal;
   786 	return returnVal;
   782 }
   787 }
   783 
   788 
   784 int TimezoneClient::getCityGroupIdByName(const QString& name)
   789 int TimezoneClient::getCityGroupIdByName(const QString& name)
   785 {
   790 {
       
   791 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETCITYGROUPIDBYNAME_ENTRY );
   786 	TPtrC namePtr;
   792 	TPtrC namePtr;
   787 	namePtr.Set(name.utf16(), name.length());
   793 	namePtr.Set(name.utf16(), name.length());
   788 
   794 
   789 	// Get the citygroup matching the name.
   795 	// Get the citygroup matching the name.
   790 	CTzLocalizedCityGroup *cityGroup = mTzLocalizer->FindCityGroupByNameL(namePtr);
   796 	CTzLocalizedCityGroup *cityGroup = mTzLocalizer->FindCityGroupByNameL(namePtr);
   794 	int id = cityGroup->Id();
   800 	int id = cityGroup->Id();
   795 
   801 
   796 	// Cleanup.
   802 	// Cleanup.
   797 	CleanupStack::PopAndDestroy(cityGroup);
   803 	CleanupStack::PopAndDestroy(cityGroup);
   798 
   804 
       
   805 	OstTraceFunctionExit0( TIMEZONECLIENT_GETCITYGROUPIDBYNAME_EXIT );
   799 	return id;
   806 	return id;
   800 }
   807 }
   801 
   808 
   802 int TimezoneClient::getCityOffsetByNameAndId(const QString& name, int tzId)
   809 int TimezoneClient::getCityOffsetByNameAndId(const QString& name, int tzId)
   803 {
   810 {
       
   811 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETCITYOFFSETBYNAMEANDID_ENTRY );
   804 	TPtrC namePtr;
   812 	TPtrC namePtr;
   805 	namePtr.Set(name.utf16(), name.length());
   813 	namePtr.Set(name.utf16(), name.length());
   806 
   814 
   807 	// Get the citygroup matching the name.
   815 	// Get the citygroup matching the name.
   808 	CTzLocalizedCityArray *cityArray = mTzLocalizer->GetCitiesL(tzId);
   816 	CTzLocalizedCityArray *cityArray = mTzLocalizer->GetCitiesL(tzId);
   819 	}
   827 	}
   820 
   828 
   821 	// Cleanup.
   829 	// Cleanup.
   822 	CleanupStack::PopAndDestroy(cityArray);
   830 	CleanupStack::PopAndDestroy(cityArray);
   823 
   831 
       
   832 	OstTraceFunctionExit0( TIMEZONECLIENT_GETCITYOFFSETBYNAMEANDID_EXIT );
   824 	return id;
   833 	return id;
   825 }
   834 }
   826 
   835 
   827 void TimezoneClient::setDateTime(QDateTime dateTime)
   836 void TimezoneClient::setDateTime(QDateTime dateTime)
   828 {
   837 {
       
   838 	OstTraceFunctionEntry0( TIMEZONECLIENT_SETDATETIME_ENTRY );
   829 	TMonth month = intToMonth(dateTime.date().month());
   839 	TMonth month = intToMonth(dateTime.date().month());
   830 	TTime current(TDateTime(
   840 	TTime current(TDateTime(
   831 			dateTime.date().year(), month, dateTime.date().day() - 1,
   841 			dateTime.date().year(), month, dateTime.date().day() - 1,
   832 			dateTime.time().hour(), dateTime.time().minute(),
   842 			dateTime.time().hour(), dateTime.time().minute(),
   833 			dateTime.time().second(), dateTime.time().msec() * 1000));
   843 			dateTime.time().second(), dateTime.time().msec() * 1000));
   834 	RTz tz;
   844 	RTz tz;
   835 	User::LeaveIfError(tz.Connect());
   845 	User::LeaveIfError(tz.Connect());
   836 	CleanupClosePushL(tz);
   846 	CleanupClosePushL(tz);
   837 	TInt ret(tz.SetHomeTime(current));
   847 	TInt ret(tz.SetHomeTime(current));
   838 	CleanupStack::PopAndDestroy(&tz);
   848 	CleanupStack::PopAndDestroy(&tz);
       
   849 OstTraceFunctionExit0( TIMEZONECLIENT_SETDATETIME_EXIT );
   839 }
   850 }
   840 
   851 
   841 void TimezoneClient::setTimeUpdateOn(bool timeUpdate)
   852 void TimezoneClient::setTimeUpdateOn(bool timeUpdate)
   842 {
   853 {
       
   854 	OstTraceFunctionEntry0( TIMEZONECLIENT_SETTIMEUPDATEON_ENTRY );
   843 	RClkSrvInterface clkSrvInterface;
   855 	RClkSrvInterface clkSrvInterface;
   844 	User::LeaveIfError(clkSrvInterface.Connect());
   856 	User::LeaveIfError(clkSrvInterface.Connect());
   845 	if (timeUpdate) {
   857 	if (timeUpdate) {
   846 		clkSrvInterface.ActivateAllProtocols();
   858 		clkSrvInterface.ActivateAllProtocols();
   847 	}
   859 	}
   848 	else {
   860 	else {
   849 		clkSrvInterface.DeActivateAllProtocols();
   861 		clkSrvInterface.DeActivateAllProtocols();
   850 	}
   862 	}
   851 	clkSrvInterface.Close();
   863 	clkSrvInterface.Close();
       
   864 OstTraceFunctionExit0( TIMEZONECLIENT_SETTIMEUPDATEON_EXIT );
   852 }
   865 }
   853 
   866 
   854 bool TimezoneClient::timeUpdateOn()
   867 bool TimezoneClient::timeUpdateOn()
   855 {
   868 {
       
   869 	OstTraceFunctionEntry0( TIMEZONECLIENT_TIMEUPDATEON_ENTRY );
   856 	TBool autoTimeUpdateOn;
   870 	TBool autoTimeUpdateOn;
   857 	RClkSrvInterface clkSrvInterface;
   871 	RClkSrvInterface clkSrvInterface;
   858 	User::LeaveIfError(clkSrvInterface.Connect());
   872 	User::LeaveIfError(clkSrvInterface.Connect());
   859 	clkSrvInterface.IsAutoTimeUpdateOn(autoTimeUpdateOn);
   873 	clkSrvInterface.IsAutoTimeUpdateOn(autoTimeUpdateOn);
   860 	clkSrvInterface.Close();
   874 	clkSrvInterface.Close();
       
   875 	OstTraceFunctionExit0( TIMEZONECLIENT_TIMEUPDATEON_EXIT );
   861 	return autoTimeUpdateOn;
   876 	return autoTimeUpdateOn;
   862 }
   877 }
   863 
   878 
   864 QStandardItemModel *TimezoneClient::locationSelectorModel()
       
   865 {
       
   866 	if (!mWorldClockModel) {
       
   867 		createWorldClockModel();
       
   868 	}
       
   869 	return mWorldClockModel;
       
   870 }
       
   871 
       
   872 TMonth TimezoneClient::intToMonth(int month)
   879 TMonth TimezoneClient::intToMonth(int month)
   873 {
   880 {
       
   881 	OstTraceFunctionEntry0( TIMEZONECLIENT_INTTOMONTH_ENTRY );
   874 	switch (month) {
   882 	switch (month) {
   875 		case 1:
   883 		case 1:
   876 			return EJanuary;
   884 			return EJanuary;
   877 		case 2:
   885 		case 2:
   878 			return EFebruary;
   886 			return EFebruary;
   901 			break;
   909 			break;
   902 	}
   910 	}
   903 	return (TMonth) -1;
   911 	return (TMonth) -1;
   904 }
   912 }
   905 
   913 
   906 void TimezoneClient::createWorldClockModel()
       
   907 {
       
   908 	// Construct the model if its not yet done
       
   909 	if (!mWorldClockModel) {
       
   910 		// Create the model
       
   911 		mWorldClockModel = new QStandardItemModel(this);
       
   912 
       
   913 		getCountries(mAllCountries);
       
   914 		mCountryCount = mAllCountries.count();
       
   915 
       
   916 		// Construct the model in asynchronously
       
   917 		QTimer::singleShot(2000, this, SLOT(populateCities()));
       
   918 	}
       
   919 }
       
   920 
       
   921 void TimezoneClient::populateCities()
   914 void TimezoneClient::populateCities()
   922 {
   915 {
       
   916 	OstTraceFunctionEntry0( TIMEZONECLIENT_POPULATECITIES_ENTRY );
   923 	// First iterate over all the counties
   917 	// First iterate over all the counties
   924 	QMapIterator<QString, int> countryIter(mAllCountries);
   918 	QMapIterator<QString, int> countryIter(mAllCountries);
   925 	while (countryIter.hasNext()) {
   919 	while (countryIter.hasNext()) {
   926 		countryIter.next();
   920 		countryIter.next();
   927 		// Create an item for each country and append it to the model
   921 		// Create an item for each country and append it to the model
   942 			// TODO: Define and use proper role
   936 			// TODO: Define and use proper role
   943 			city->setData(cityIter.value(), Qt::UserRole + 200);
   937 			city->setData(cityIter.value(), Qt::UserRole + 200);
   944 			country->appendRow(city);
   938 			country->appendRow(city);
   945 		}
   939 		}
   946 	}
   940 	}
       
   941 OstTraceFunctionExit0( TIMEZONECLIENT_POPULATECITIES_EXIT );
   947 }
   942 }
   948 
   943 
   949 /*!
   944 /*!
   950 	 Checks if DST changes will be applied in the next 24 hours.
   945 	 Checks if DST changes will be applied in the next 24 hours.
   951 
   946 
   952 	 \param alarmInfo reference to alarm info
   947 	 \param alarmInfo reference to alarm info
   953 	 \return true if there is DST change otherwise false
   948 	 \return true if there is DST change otherwise false
   954  */
   949  */
   955 bool TimezoneClient::checkForDstChange(AlarmInfo& alarmInfo)
   950 bool TimezoneClient::checkForDstChange(AlarmInfo& alarmInfo)
   956 {
   951 {
       
   952 	OstTraceFunctionEntry0( TIMEZONECLIENT_CHECKFORDSTCHANGE_ENTRY );
   957 	// User to be notified whether DST rollover happens in a day or
   953 	// User to be notified whether DST rollover happens in a day or
   958 	// has happen within a day if he tries to change the time.
   954 	// has happen within a day if he tries to change the time.
   959 	bool returnValue( EFalse );
   955 	bool returnValue( EFalse );
   960 
   956 
   961 	// Establish connection with RTz to get the timezone ID
   957 	// Establish connection with RTz to get the timezone ID
  1079 	CleanupStack::PopAndDestroy( vActualisedRules);
  1075 	CleanupStack::PopAndDestroy( vActualisedRules);
  1080 	CleanupStack::PopAndDestroy( currentRules );
  1076 	CleanupStack::PopAndDestroy( currentRules );
  1081 	CleanupStack::PopAndDestroy( currentTZId );
  1077 	CleanupStack::PopAndDestroy( currentTZId );
  1082 	CleanupStack::PopAndDestroy( &tzHandle );
  1078 	CleanupStack::PopAndDestroy( &tzHandle );
  1083 
  1079 
       
  1080 	OstTraceFunctionExit0( TIMEZONECLIENT_CHECKFORDSTCHANGE_EXIT );
  1084 	return returnValue;
  1081 	return returnValue;
  1085 }
  1082 }
  1086 
  1083 
  1087 /*!
  1084 /*!
  1088 	Get all time zone ids
  1085 	Get all time zone ids
  1089 
  1086 
  1090 	\return list of time zone ids
  1087 	\return list of time zone ids
  1091  */
  1088  */
  1092 QList<int> TimezoneClient::getAllTimeZoneIds()
  1089 QList<int> TimezoneClient::getAllTimeZoneIds()
  1093 {
  1090 {
       
  1091 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETALLTIMEZONEIDS_ENTRY );
  1094 	if (mTimeZoneIds.count()) {
  1092 	if (mTimeZoneIds.count()) {
       
  1093 		OstTraceFunctionExit0( TIMEZONECLIENT_GETALLTIMEZONEIDS_EXIT );
  1095 		return mTimeZoneIds;
  1094 		return mTimeZoneIds;
  1096 	} else {
  1095 	} else {
  1097 		// This list will contain the info of the cities fetched from tz server.
  1096 		// This list will contain the info of the cities fetched from tz server.
  1098 		QList<LocationInfo> infoList;
  1097 		QList<LocationInfo> infoList;
  1099 
  1098 
  1113 				mTimeZoneIds.append(tzId);
  1112 				mTimeZoneIds.append(tzId);
  1114 			}
  1113 			}
  1115 		}
  1114 		}
  1116 
  1115 
  1117 		CleanupStack::PopAndDestroy(cityArray);
  1116 		CleanupStack::PopAndDestroy(cityArray);
       
  1117 		OstTraceFunctionExit0( DUP1_TIMEZONECLIENT_GETALLTIMEZONEIDS_EXIT );
  1118 		return mTimeZoneIds;
  1118 		return mTimeZoneIds;
  1119 	}
  1119 	}
  1120 }
  1120 }
  1121 
  1121 
  1122 /*!
  1122 /*!
  1124 
  1124 
  1125 	\return list of time zone ids
  1125 	\return list of time zone ids
  1126  */
  1126  */
  1127 QList<int> TimezoneClient::getAllTimeZoneOffsets()
  1127 QList<int> TimezoneClient::getAllTimeZoneOffsets()
  1128 {
  1128 {
       
  1129 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETALLTIMEZONEOFFSETS_ENTRY );
  1129 	QList<int> timeZoneOffsetList;
  1130 	QList<int> timeZoneOffsetList;
  1130 	QList<int> timeZoneIdList;
  1131 	QList<int> timeZoneIdList;
  1131 	if (mTimeZoneIds.count()) {
  1132 	if (mTimeZoneIds.count()) {
  1132 		timeZoneIdList = mTimeZoneIds;
  1133 		timeZoneIdList = mTimeZoneIds;
  1133 	} else {
  1134 	} else {
  1159 
  1160 
  1160 	tzHandle.Close();
  1161 	tzHandle.Close();
  1161 	CleanupStack::PopAndDestroy( &tzHandle );
  1162 	CleanupStack::PopAndDestroy( &tzHandle );
  1162 	// Sort the offset list
  1163 	// Sort the offset list
  1163 	qSort(timeZoneOffsetList.begin(),timeZoneOffsetList.end());
  1164 	qSort(timeZoneOffsetList.begin(),timeZoneOffsetList.end());
       
  1165 	OstTraceFunctionExit0( TIMEZONECLIENT_GETALLTIMEZONEOFFSETS_EXIT );
  1164 	return timeZoneOffsetList;
  1166 	return timeZoneOffsetList;
  1165 }
  1167 }
  1166 
  1168 
  1167 
  1169 
  1168 /*!
  1170 /*!
  1170 
  1172 
  1171 	\param list of countries infomation having the same UTC offsets
  1173 	\param list of countries infomation having the same UTC offsets
  1172  */
  1174  */
  1173 QList<LocationInfo> TimezoneClient::getCountriesForUTCOffset(int utcOffset)
  1175 QList<LocationInfo> TimezoneClient::getCountriesForUTCOffset(int utcOffset)
  1174 {
  1176 {
       
  1177 	OstTraceFunctionEntry0( TIMEZONECLIENT_GETCOUNTRIESFORUTCOFFSET_ENTRY );
  1175 	// This list will contain the info of the countries.
  1178 	// This list will contain the info of the countries.
  1176 	QList<LocationInfo> countryList;
  1179 	QList<LocationInfo> countryList;
  1177 	QList<int> cityGroupIdList;
  1180 	QList<int> cityGroupIdList;
  1178 
  1181 
  1179 	// Get all cities for the UTC offset.
  1182 	// Get all cities for the UTC offset.
  1204 			delete country;
  1207 			delete country;
  1205 		}
  1208 		}
  1206 	}
  1209 	}
  1207 	cityGroupIdList.clear();
  1210 	cityGroupIdList.clear();
  1208 	CleanupStack::PopAndDestroy(cityList);
  1211 	CleanupStack::PopAndDestroy(cityList);
       
  1212 	OstTraceFunctionExit0( TIMEZONECLIENT_GETCOUNTRIESFORUTCOFFSET_EXIT );
  1209 	return countryList;
  1213 	return countryList;
  1210 }
  1214 }
  1211 
  1215 
  1212 /*!
  1216 /*!
  1213 	Add a new city to the city list using the
  1217 	Add a new city to the city list using the
  1218 	\cityGroupId Group Id of the country
  1222 	\cityGroupId Group Id of the country
  1219  */
  1223  */
  1220 LocationInfo TimezoneClient::addCity(
  1224 LocationInfo TimezoneClient::addCity(
  1221 		int timeZoneId,QString &cityName,int cityGroupId)
  1225 		int timeZoneId,QString &cityName,int cityGroupId)
  1222 {
  1226 {
       
  1227 	OstTraceFunctionEntry0( TIMEZONECLIENT_ADDCITY_ENTRY );
  1223 	TPtrC namePtr;
  1228 	TPtrC namePtr;
  1224 	namePtr.Set(cityName.utf16(), cityName.length());
  1229 	namePtr.Set(cityName.utf16(), cityName.length());
  1225 
  1230 
  1226 	// Add a new city using the localizer
  1231 	// Add a new city using the localizer
  1227 	CTzLocalizedCity* newCity =
  1232 	CTzLocalizedCity* newCity =
  1235 	info.cityName = QString::fromUtf16(
  1240 	info.cityName = QString::fromUtf16(
  1236 			newCityName.Ptr(), newCityName.Length());
  1241 			newCityName.Ptr(), newCityName.Length());
  1237 
  1242 
  1238 	CleanupStack::PopAndDestroy(newCity);
  1243 	CleanupStack::PopAndDestroy(newCity);
  1239 
  1244 
       
  1245 	OstTraceFunctionExit0( TIMEZONECLIENT_ADDCITY_EXIT );
  1240 	return info;
  1246 	return info;
  1241 }
  1247 }
  1242 
  1248 
  1243 /*!
  1249 /*!
  1244 	Slot which is called when the value changes in cevrep.
  1250 	Slot which is called when the value changes in cevrep.
  1246 	\param key The key which got changed in cenrep.
  1252 	\param key The key which got changed in cenrep.
  1247 	\param value The new value of that key.
  1253 	\param value The new value of that key.
  1248  */
  1254  */
  1249 void TimezoneClient::eventMonitor(const XQSettingsKey& key, const QVariant& value)
  1255 void TimezoneClient::eventMonitor(const XQSettingsKey& key, const QVariant& value)
  1250 {
  1256 {
       
  1257 	OstTraceFunctionEntry0( TIMEZONECLIENT_EVENTMONITOR_ENTRY );
  1251 	if (key.uid() == KCRUidNitz && key.key() == KActiveProtocol) {
  1258 	if (key.uid() == KCRUidNitz && key.key() == KActiveProtocol) {
  1252 		if (mSettingsManager->error() == XQSettingsManager::NoError) {
  1259 		if (mSettingsManager->error() == XQSettingsManager::NoError) {
  1253 
  1260 
  1254 			// New value of auto time update.
  1261 			// New value of auto time update.
  1255 			int autoTimeUpdate = value.toInt();
  1262 			int autoTimeUpdate = value.toInt();
  1261 				mAutoTimeUpdateValue = autoTimeUpdate;
  1268 				mAutoTimeUpdateValue = autoTimeUpdate;
  1262 				emit autoTimeUpdateChanged(mAutoTimeUpdateValue);
  1269 				emit autoTimeUpdateChanged(mAutoTimeUpdateValue);
  1263 			}
  1270 			}
  1264 		}
  1271 		}
  1265 	}
  1272 	}
       
  1273 OstTraceFunctionExit0( TIMEZONECLIENT_EVENTMONITOR_EXIT );
       
  1274 }
       
  1275 
       
  1276 void TimezoneClient::notifyTimeChange()
       
  1277 {
       
  1278 	OstTraceFunctionEntry0( TIMEZONECLIENT_NOTIFYTIMECHANGE_ENTRY );
       
  1279 	emit timechanged();
       
  1280 OstTraceFunctionExit0( TIMEZONECLIENT_NOTIFYTIMECHANGE_EXIT );
  1266 }
  1281 }
  1267 // End of file	--Don't remove this.
  1282 // End of file	--Don't remove this.