1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1997-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". |
23 #include "tzlocalizationdb.h" |
23 #include "tzlocalizationdb.h" |
24 #include <bautils.h> |
24 #include <bautils.h> |
25 #include "CBackupRestoreNotification.h" |
25 #include "CBackupRestoreNotification.h" |
26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
27 #include <tzuserdefineddata.h> |
27 #include <tzuserdefineddata.h> |
|
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "timezoneconfigTraces.h" |
|
31 #endif |
|
32 |
28 #endif |
33 #endif |
29 |
34 |
30 _LIT8(KUnknownTZName, "Unknown/Zone"); |
35 _LIT8(KUnknownTZName, "Unknown/Zone"); |
31 |
36 |
32 const TUint32 KUnknownTZId = 0x0ffffff0; |
37 const TUint32 KUnknownTZId = 0x0ffffff0; |
222 PublishTzDbChangeInfoL(); |
227 PublishTzDbChangeInfoL(); |
223 } |
228 } |
224 |
229 |
225 void CTzConfigAgent::PublishTzDbChangeInfoL() |
230 void CTzConfigAgent::PublishTzDbChangeInfoL() |
226 { |
231 { |
|
232 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_PUBLISHTZDBCHANGEINFOL_ENTRY, "CTzConfigAgent::PublishTzDbChangeInfoL Entry" ); |
|
233 |
|
234 |
227 RFile file; |
235 RFile file; |
228 CleanupClosePushL(file); |
236 CleanupClosePushL(file); |
229 |
237 |
230 TTime tzDbModified = Time::NullTTime(); |
238 TTime tzDbModified = Time::NullTTime(); |
231 TTime userDbModified = Time::NullTTime(); |
239 TTime userDbModified = Time::NullTTime(); |
297 { |
305 { |
298 //Publish the tz rules change |
306 //Publish the tz rules change |
299 NTzUpdate::TTzRulesChange rulesChange; |
307 NTzUpdate::TTzRulesChange rulesChange; |
300 rulesChange.iUTCTimeOfRulesChange.UniversalTime(); |
308 rulesChange.iUTCTimeOfRulesChange.UniversalTime(); |
301 TPckgBuf<NTzUpdate::TTzRulesChange> bufRules(rulesChange); |
309 TPckgBuf<NTzUpdate::TTzRulesChange> bufRules(rulesChange); |
|
310 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, PUBLISH_UPDATE_NOTIFICATION, TZRULES_CHANGE_NOTIFICATION_2, "Time zone rules change" ); |
|
311 |
302 RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzRulesChange, bufRules); |
312 RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzRulesChange, bufRules); |
303 } |
313 } |
304 |
314 |
305 if(tzNameChanged ) |
315 if(tzNameChanged ) |
306 { |
316 { |
307 //Publish the names change for user defined DB or resource file change |
317 //Publish the names change for user defined DB or resource file change |
308 NTzUpdate::TTzNamesChange namesChange; |
318 NTzUpdate::TTzNamesChange namesChange; |
309 namesChange.iUTCTimeOfNamesChange.UniversalTime(); |
319 namesChange.iUTCTimeOfNamesChange.UniversalTime(); |
310 TPckgBuf<NTzUpdate::TTzNamesChange> bufNames(namesChange); |
320 TPckgBuf<NTzUpdate::TTzNamesChange> bufNames(namesChange); |
|
321 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, PUBLISH_UPDATE_NOTIFICATION, TZNAMES_CHANGE_NOTIFICATION_2, "Time zone names change notification" ); |
|
322 |
311 RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzNamesChange, bufNames); |
323 RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzNamesChange, bufNames); |
312 } |
324 } |
313 } |
325 } |
|
326 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_PUBLISHTZDBCHANGEINFOL_EXIT, "CTzConfigAgent::PublishTzDbChangeInfoL Exit" ); |
|
327 |
314 } |
328 } |
315 |
329 |
316 void CTzConfigAgent::ReadTimeStampsL(RFile& aFile, TTime& aTzdbSaved, TTime& aUserDbSaved, TTime& aResourceFileSaved) |
330 void CTzConfigAgent::ReadTimeStampsL(RFile& aFile, TTime& aTzdbSaved, TTime& aUserDbSaved, TTime& aResourceFileSaved) |
317 { |
331 { |
|
332 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_READTIMESTAMPSL_ENTRY, "CTzConfigAgent::ReadTimeStampsL Entry" ); |
|
333 |
318 RFileReadStream readStream(aFile); |
334 RFileReadStream readStream(aFile); |
319 CleanupClosePushL(readStream); |
335 CleanupClosePushL(readStream); |
320 |
336 |
321 TUint32 low = readStream.ReadUint32L(); |
337 TUint32 low = readStream.ReadUint32L(); |
322 TUint32 high = readStream.ReadUint32L(); |
338 TUint32 high = readStream.ReadUint32L(); |
328 |
344 |
329 low = readStream.ReadUint32L(); |
345 low = readStream.ReadUint32L(); |
330 high = readStream.ReadUint32L(); |
346 high = readStream.ReadUint32L(); |
331 aResourceFileSaved = TTime(MAKE_TINT64(high, low)); |
347 aResourceFileSaved = TTime(MAKE_TINT64(high, low)); |
332 CleanupStack::PopAndDestroy(&readStream); |
348 CleanupStack::PopAndDestroy(&readStream); |
|
349 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_READTIMESTAMPSL_EXIT, "CTzConfigAgent::ReadTimeStampsL Exit" ); |
|
350 |
333 } |
351 } |
334 |
352 |
335 void CTzConfigAgent::WriteTimeStampsL(RFile& aFile, const TTime& aTzdbModified, const TTime& aUserDbModified, const TTime& aResourceFileModified) |
353 void CTzConfigAgent::WriteTimeStampsL(RFile& aFile, const TTime& aTzdbModified, const TTime& aUserDbModified, const TTime& aResourceFileModified) |
336 { |
354 { |
337 RFileWriteStream writeStream(aFile); |
355 RFileWriteStream writeStream(aFile); |
349 /* Get the sum of time stamps of time zone resource files |
367 /* Get the sum of time stamps of time zone resource files |
350 * It returns Time::NullTTime() if there is no resorece files in the "c:\\resource\\timezonelocalization\\" |
368 * It returns Time::NullTTime() if there is no resorece files in the "c:\\resource\\timezonelocalization\\" |
351 */ |
369 */ |
352 TTime CTzConfigAgent::GetResourceFileTimeStampsL() |
370 TTime CTzConfigAgent::GetResourceFileTimeStampsL() |
353 { |
371 { |
|
372 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_GETRESOURCEFILETIMESTAMPSL_ENTRY, "CTzConfigAgent::GetResourceFileTimeStampsL Entry" ); |
|
373 |
354 CDir* files = NULL; |
374 CDir* files = NULL; |
355 TInt err = iFs.GetDir(KResourceDir, KEntryAttNormal, ESortNone, files); |
375 TInt err = iFs.GetDir(KResourceDir, KEntryAttNormal, ESortNone, files); |
356 CleanupStack::PushL(files); |
376 CleanupStack::PushL(files); |
357 TInt64 sum = 0; |
377 TInt64 sum = 0; |
358 if(err != KErrNone && err != KErrNotFound && err != KErrPathNotFound) |
378 if(err != KErrNone && err != KErrNotFound && err != KErrPathNotFound) |
367 const TEntry& entry = (*files)[ii]; |
387 const TEntry& entry = (*files)[ii]; |
368 sum = sum + entry.iModified.Int64(); |
388 sum = sum + entry.iModified.Int64(); |
369 } |
389 } |
370 } |
390 } |
371 CleanupStack::PopAndDestroy(files); |
391 CleanupStack::PopAndDestroy(files); |
|
392 OstTraceDefExt1( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_GETRESOURCEFILETIMESTAMPSL_EXIT, "CTzConfigAgent::GetResourceFileTimeStampsL Exit;sum=%Ld", sum ); |
|
393 |
372 if(sum==0) |
394 if(sum==0) |
373 { |
395 { |
|
396 |
374 return Time::NullTTime(); |
397 return Time::NullTTime(); |
375 } |
398 } |
|
399 |
376 return TTime(sum); |
400 return TTime(sum); |
377 } |
401 } |
378 |
402 |
379 void CTzConfigAgent::PublishNewDstChangeInfoL() |
403 void CTzConfigAgent::PublishNewDstChangeInfoL() |
380 { |
404 { |
|
405 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_PUBLISHNEWDSTCHANGEINFOL_ENTRY, "CTzConfigAgent::PublishNewDstChangeInfoL Entry" ); |
|
406 |
|
407 |
381 TInt propertyDefineError = RProperty::Define(KUidSystemCategory, |
408 TInt propertyDefineError = RProperty::Define(KUidSystemCategory, |
382 KNextDSTChangePropertyKey, |
409 KNextDSTChangePropertyKey, |
383 RProperty::EByteArray, |
410 RProperty::EByteArray, |
384 KReadPolicy, |
411 KReadPolicy, |
385 KWritePolicy, |
412 KWritePolicy, |
386 sizeof(NTzUpdate::TDSTChangeInfo)); |
413 sizeof(NTzUpdate::TDSTChangeInfo)); |
387 |
414 |
388 if (propertyDefineError != KErrAlreadyExists) |
415 if (propertyDefineError != KErrAlreadyExists) |
389 { |
416 { |
390 // if there was an actual error defining the property then we should leave |
417 // if there was an actual error defining the property then we should leave |
|
418 OstTraceDef1( OST_TRACE_CATEGORY_DEBUG,TRACE_ERROR, PROPERTY_DEFINITION, "Property definition return value: =%d", propertyDefineError ); |
|
419 |
391 User::LeaveIfError(propertyDefineError); |
420 User::LeaveIfError(propertyDefineError); |
392 } |
421 } |
393 |
422 |
394 // create the next DST change and set some default values |
423 // create the next DST change and set some default values |
395 NTzUpdate::TDSTChangeInfo newDSTChangeInfo; |
424 NTzUpdate::TDSTChangeInfo newDSTChangeInfo; |
422 || (currentNextDSTChangeBuf().iPreviousDSTChangeUTC != newDSTChangeInfo.iPreviousDSTChangeUTC) |
451 || (currentNextDSTChangeBuf().iPreviousDSTChangeUTC != newDSTChangeInfo.iPreviousDSTChangeUTC) |
423 || (propertyDefineError != KErrAlreadyExists)) |
452 || (propertyDefineError != KErrAlreadyExists)) |
424 { |
453 { |
425 // package the data and set the property value |
454 // package the data and set the property value |
426 TPckgBuf<NTzUpdate::TDSTChangeInfo> newDSTChangeInfoBuf(newDSTChangeInfo); |
455 TPckgBuf<NTzUpdate::TDSTChangeInfo> newDSTChangeInfoBuf(newDSTChangeInfo); |
|
456 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,PUBLISH_UPDATE_NOTIFICATION, NEXT_DST_CHANGE, "Publish New Dst Change " ); |
|
457 |
427 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KNextDSTChangePropertyKey, newDSTChangeInfoBuf)); |
458 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KNextDSTChangePropertyKey, newDSTChangeInfoBuf)); |
428 } |
459 } |
|
460 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_PUBLISHNEWDSTCHANGEINFOL_EXIT, "CTzConfigAgent::PublishNewDstChangeInfoL Exit" ); |
|
461 |
429 } |
462 } |
430 |
463 |
431 /* |
464 /* |
432 */ |
465 */ |
433 CTzConfigAgent* CTzConfigAgent::NewL(MTZCfgAgentObserver& aServer, CTzUserDataDb& aUserDataDb, |
466 CTzConfigAgent* CTzConfigAgent::NewL(MTZCfgAgentObserver& aServer, CTzUserDataDb& aUserDataDb, |
434 CTzSwiObserver& aTzSwiObserver) |
467 CTzSwiObserver& aTzSwiObserver) |
435 { |
468 { |
|
469 |
436 CTzConfigAgent* self = new(ELeave) CTzConfigAgent(aServer, aUserDataDb, aTzSwiObserver); |
470 CTzConfigAgent* self = new(ELeave) CTzConfigAgent(aServer, aUserDataDb, aTzSwiObserver); |
437 CleanupStack::PushL(self); |
471 CleanupStack::PushL(self); |
438 self->ConstructL(); |
472 self->ConstructL(); |
439 CleanupStack::Pop(self); |
473 CleanupStack::Pop(self); |
440 return self; |
474 return self; |
450 return iSystemTzCache->TimeZoneId(); |
484 return iSystemTzCache->TimeZoneId(); |
451 } |
485 } |
452 |
486 |
453 const CTzId& CTzConfigAgent::SetTimeZoneL(const CTzId& aZoneId, const TAny* aRequester, TBool aUpdateCentralRepository, TBool aForceCacheUpdate) |
487 const CTzId& CTzConfigAgent::SetTimeZoneL(const CTzId& aZoneId, const TAny* aRequester, TBool aUpdateCentralRepository, TBool aForceCacheUpdate) |
454 { |
488 { |
|
489 OstTraceDefExt3(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_SETTIMEZONEL_ENTRY, "CTzConfigAgent::SetTimeZoneL Entry;aZoneId=%u;aUpdateCentralRepository=%u;aForceCacheUpdate=%u", aZoneId.TimeZoneNumericID(), aUpdateCentralRepository, aForceCacheUpdate ); |
|
490 |
|
491 |
455 TInt oldTzId = 0; |
492 TInt oldTzId = 0; |
456 TBool zoneChanged = EFalse; |
493 TBool zoneChanged = EFalse; |
457 TTime now; |
494 TTime now; |
458 now.UniversalTime(); |
495 now.UniversalTime(); |
459 |
496 |
474 |
511 |
475 //For Invalid Timezone, rules doesnot exist |
512 //For Invalid Timezone, rules doesnot exist |
476 CTzRules& newZoneRules = newZone->GetEncodedTimeZoneRulesL(); |
513 CTzRules& newZoneRules = newZone->GetEncodedTimeZoneRulesL(); |
477 if (newZoneRules.Count() == 0) |
514 if (newZoneRules.Count() == 0) |
478 { |
515 { |
|
516 OstTraceDef1( OST_TRACE_CATEGORY_DEBUG,TRACE_ERROR, INVALID_TIME_ZONE, "Invalid Time zone;KErrNotFound=%u", KErrNotFound ); |
|
517 |
479 User::Leave(KErrNotFound); |
518 User::Leave(KErrNotFound); |
480 } |
519 } |
481 |
520 |
482 delete iSystemTzCache; |
521 delete iSystemTzCache; |
483 iSystemTzCache = newZone; |
522 iSystemTzCache = newZone; |
539 } |
578 } |
540 |
579 |
541 iTzDataProvider->ReleaseTzRules(); |
580 iTzDataProvider->ReleaseTzRules(); |
542 |
581 |
543 TRAP_IGNORE(PublishNewDstChangeInfoL()); |
582 TRAP_IGNORE(PublishNewDstChangeInfoL()); |
|
583 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_SETTIMEZONEL_EXIT, "CTzConfigAgent::SetTimeZoneL Exit;retun value;Time Zone Id=%u;Time Zone Name=%s", iSystemTzCache->TimeZoneId().TimeZoneNumericID(), iSystemTzCache->TimeZoneId().TimeZoneNameID() ); |
|
584 |
544 |
585 |
545 return (iSystemTzCache->TimeZoneId()); |
586 return (iSystemTzCache->TimeZoneId()); |
546 } |
587 } |
547 |
588 |
548 CTzRules& CTzConfigAgent::GetEncodedTimeZoneRulesL() |
589 CTzRules& CTzConfigAgent::GetEncodedTimeZoneRulesL() |
669 |
710 |
670 // There is a change to the TZ database. A new one may have been installed |
711 // There is a change to the TZ database. A new one may have been installed |
671 // Reset the current time zone information to take advantage of any changes. |
712 // Reset the current time zone information to take advantage of any changes. |
672 void CTzConfigAgent::NotifyTZDataStatusChangeL(RTz::TTzChanges aChange) |
713 void CTzConfigAgent::NotifyTZDataStatusChangeL(RTz::TTzChanges aChange) |
673 { |
714 { |
|
715 OstTraceDef1( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_NOTIFYTZDATASTATUSCHANGEL_ENTRY, "CTzConfigAgent::NotifyTZDataStatusChangeL Entry;aChange=%u", aChange ); |
|
716 |
674 if (aChange == RTz::ETZLocalizationDataChanged) |
717 if (aChange == RTz::ETZLocalizationDataChanged) |
675 { |
718 { |
676 TInt j = 0; |
719 TInt j = 0; |
677 TInt jEnd = iChangeObservers.Count(); |
720 TInt jEnd = iChangeObservers.Count(); |
678 while (j < jEnd) |
721 while (j < jEnd) |
682 } |
725 } |
683 |
726 |
684 NTzUpdate::TTzNamesChange namesChange; |
727 NTzUpdate::TTzNamesChange namesChange; |
685 namesChange.iUTCTimeOfNamesChange.UniversalTime(); |
728 namesChange.iUTCTimeOfNamesChange.UniversalTime(); |
686 TPckgBuf<NTzUpdate::TTzNamesChange> bufNames(namesChange); |
729 TPckgBuf<NTzUpdate::TTzNamesChange> bufNames(namesChange); |
|
730 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, PUBLISH_UPDATE_NOTIFICATION, TZNAMES_CHANGE_NOTIFICATION, "Time zone names change notification" ); |
|
731 |
687 User::LeaveIfError(RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzNamesChange, bufNames)); |
732 User::LeaveIfError(RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzNamesChange, bufNames)); |
688 } |
733 } |
689 else |
734 else |
690 { |
735 { |
691 delete iOtherTzCache; |
736 delete iOtherTzCache; |
698 |
743 |
699 //Publish the property |
744 //Publish the property |
700 NTzUpdate::TTzRulesChange rulesChange; |
745 NTzUpdate::TTzRulesChange rulesChange; |
701 rulesChange.iUTCTimeOfRulesChange.UniversalTime(); |
746 rulesChange.iUTCTimeOfRulesChange.UniversalTime(); |
702 TPckgBuf<NTzUpdate::TTzRulesChange> bufRules(rulesChange); |
747 TPckgBuf<NTzUpdate::TTzRulesChange> bufRules(rulesChange); |
|
748 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, PUBLISH_UPDATE_NOTIFICATION, TZRULES_CHANGE_NOTIFICATION, "Time zone rules change notification" ); |
|
749 |
703 User::LeaveIfError(RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzRulesChange, bufRules)); |
750 User::LeaveIfError(RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzRulesChange, bufRules)); |
704 } |
751 } |
|
752 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_NOTIFYTZDATASTATUSCHANGEL_EXIT, "CTzConfigAgent::NotifyTZDataStatusChangeL Exit" ); |
|
753 |
705 } |
754 } |
706 |
755 |
707 /** |
756 /** |
708 Calculates the time/date (in UTC) of the next DST change event that will take |
757 Calculates the time/date (in UTC) of the next DST change event that will take |
709 place for the current time zone. Note that there may not be a DST change for |
758 place for the current time zone. Note that there may not be a DST change for |
732 @internalComponent |
781 @internalComponent |
733 |
782 |
734 */ |
783 */ |
735 TBool CTzConfigAgent::CalculateNextDstChangeL(TTime& aNextDstEvent, TTime& aPreviousDstEvent) |
784 TBool CTzConfigAgent::CalculateNextDstChangeL(TTime& aNextDstEvent, TTime& aPreviousDstEvent) |
736 { |
785 { |
|
786 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_CALCULATENEXTDSTCHANGEL_ENTRY, "CTzConfigAgent::CalculateNextDstChangeL Entry" ); |
|
787 |
737 // Get the current time/date. |
788 // Get the current time/date. |
738 TTime now; |
789 TTime now; |
739 now.UniversalTime(); |
790 now.UniversalTime(); |
740 |
791 |
741 // Get the actualised rules for the current time zone |
792 // Get the actualised rules for the current time zone |
783 aPreviousDstEvent = utcTimeOfChange; |
834 aPreviousDstEvent = utcTimeOfChange; |
784 } |
835 } |
785 else |
836 else |
786 { |
837 { |
787 aNextDstEvent = utcTimeOfChange; |
838 aNextDstEvent = utcTimeOfChange; |
|
839 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_CALCULATENEXTDSTCHANGEL_EXIT2, "CTzConfigAgent::CalculateNextDstChangeL :DST has changed" ); |
|
840 |
788 return ETrue; |
841 return ETrue; |
789 } |
842 } |
790 } |
843 } |
791 |
844 |
792 // No DST change has been found. |
845 // No DST change has been found. |
|
846 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_CALCULATENEXTDSTCHANGEL_EXIT, "CTzConfigAgent::CalculateNextDstChangeL Exit: No DST change" ); |
|
847 |
793 return EFalse; |
848 return EFalse; |
794 } |
849 } |
795 |
850 |
796 |
851 |
797 /** |
852 /** |
865 SetDstChangeTimerL(); |
923 SetDstChangeTimerL(); |
866 |
924 |
867 // Publish update notification. |
925 // Publish update notification. |
868 // Note that the value published is the same as |
926 // Note that the value published is the same as |
869 // the AutoUpdate Configuration |
927 // the AutoUpdate Configuration |
|
928 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,PUBLISH_UPDATE_NOTIFICATION, UTC_OFF_SET_CHANGE, "CTzConfigAgent::HandleDstChangeTimerL:EUtcOffsetChangeNotification" ); |
|
929 |
870 TInt err = RProperty::Set( |
930 TInt err = RProperty::Set( |
871 NTzUpdate::KPropertyCategory, |
931 NTzUpdate::KPropertyCategory, |
872 NTzUpdate::EUtcOffsetChangeNotification, iEnabled); |
932 NTzUpdate::EUtcOffsetChangeNotification, iEnabled); |
|
933 |
873 User::LeaveIfError(err); |
934 User::LeaveIfError(err); |
874 } |
935 } |
875 |
936 |
876 TRAP_IGNORE(PublishNewDstChangeInfoL()); |
937 TRAP_IGNORE(PublishNewDstChangeInfoL()); |
|
938 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_HANDLEDSTCHANGETIMERL_EXIT, "CTzConfigAgent::HandleDstChangeTimerL Exit" ); |
|
939 |
877 } |
940 } |
878 |
941 |
879 |
942 |
880 /** |
943 /** |
881 Calculates what the UTC Offset should be - if this differs from the current |
944 Calculates what the UTC Offset should be - if this differs from the current |
916 @internalComponent |
979 @internalComponent |
917 |
980 |
918 */ |
981 */ |
919 void CTzConfigAgent::SetAutoUpdateBehaviorL(TInt aUpdateEnabled) |
982 void CTzConfigAgent::SetAutoUpdateBehaviorL(TInt aUpdateEnabled) |
920 { |
983 { |
|
984 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_SETAUTOUPDATEBEHAVIORL_ENTRY, "CTzConfigAgent::SetAutoUpdateBehaviorL Entry;aUpdateEnabled=%u", aUpdateEnabled ); |
|
985 |
|
986 |
921 // Check if the configuration has changed. |
987 // Check if the configuration has changed. |
922 if (aUpdateEnabled != iEnabled) |
988 if (aUpdateEnabled != iEnabled) |
923 { |
989 { |
924 // Persist the new configuration. |
990 // Persist the new configuration. |
925 iEnabled = aUpdateEnabled; |
991 iEnabled = aUpdateEnabled; |
958 @internalComponent |
1026 @internalComponent |
959 |
1027 |
960 */ |
1028 */ |
961 TInt CTzConfigAgent::SetHomeTimeL(const TTime& aHomeTime) |
1029 TInt CTzConfigAgent::SetHomeTimeL(const TTime& aHomeTime) |
962 { |
1030 { |
|
1031 OstTraceDefExt5(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_SETHOMETIMEL_ENTRY, "CTzConfigAgent::SetHomeTimeL Entry;YY=%d;MM=%d;DD=%d;HH=%d;Min=%d", aHomeTime.DateTime().Year(),aHomeTime.DateTime().Month(),aHomeTime.DateTime().Day(),aHomeTime.DateTime().Hour(), aHomeTime.DateTime().Minute() ); |
|
1032 OstTraceDef1( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_SETHOMETIMEL_PARAM, "Parameter..;SS=%d", aHomeTime.DateTime().Second() ); |
|
1033 |
963 TTime utcTime(aHomeTime); |
1034 TTime utcTime(aHomeTime); |
964 |
1035 |
965 ConvertL(utcTime, ETzWallTimeReference); |
1036 ConvertL(utcTime, ETzWallTimeReference); |
966 |
1037 |
967 //Cancel environment change notification in case double updating UTC offset. |
1038 //Cancel environment change notification in case double updating UTC offset. |
990 |
1061 |
991 //Restart observe environment change notification. |
1062 //Restart observe environment change notification. |
992 iChangeNotifier->Start(); |
1063 iChangeNotifier->Start(); |
993 |
1064 |
994 TRAP_IGNORE(PublishNewDstChangeInfoL()); |
1065 TRAP_IGNORE(PublishNewDstChangeInfoL()); |
995 |
1066 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_SETHOMETIMEL_EXIT, "CTzConfigAgent::SetHomeTimeL Exit;result=%u", result ); |
996 return result; |
1067 return result; |
997 } |
1068 } |
998 |
1069 |
999 TInt CTzConfigAgent::SetUnknownTimeZoneTimeL(const TTime& aUTCTime, const TInt aUTCOffset, TBool aPersistInCenRep) |
1070 TInt CTzConfigAgent::SetUnknownTimeZoneTimeL(const TTime& aUTCTime, const TInt aUTCOffset, TBool aPersistInCenRep) |
1000 { |
1071 { |
|
1072 |
|
1073 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_SETUNKNOWNTIMEZONETIMEL_ENTRY, "CTzConfigAgent::SetUnknownTimeZoneTimeL Entry;aUTCOffset=%d;aPersistInCenRep=%u", aUTCOffset, aPersistInCenRep ); |
|
1074 |
1001 // |
1075 // |
1002 // Cancel DST timer. (It will not be restarted, as we won't have DST rules for this unknown zone) |
1076 // Cancel DST timer. (It will not be restarted, as we won't have DST rules for this unknown zone) |
1003 // |
1077 // |
1004 iDstTimer->Cancel(); |
1078 iDstTimer->Cancel(); |
1005 |
1079 |
1014 TInt result = User::SetUTCTimeAndOffset(aUTCTime, newUtcOffset); |
1088 TInt result = User::SetUTCTimeAndOffset(aUTCTime, newUtcOffset); |
1015 // |
1089 // |
1016 // Restart environment change notification. |
1090 // Restart environment change notification. |
1017 // |
1091 // |
1018 iChangeNotifier->Start(); |
1092 iChangeNotifier->Start(); |
1019 |
1093 |
1020 User::LeaveIfError(result); |
1094 User::LeaveIfError(result); |
1021 |
1095 |
1022 TInt oldTzId = iSystemTzCache->TimeZoneId().TimeZoneNumericID(); |
1096 TInt oldTzId = iSystemTzCache->TimeZoneId().TimeZoneNumericID(); |
1023 |
1097 |
1024 // replace the rule, create an new unknown before deleting old |
1098 // replace the rule, create an new unknown before deleting old |
1054 NTzUpdate::TTimeZoneChange change; |
1128 NTzUpdate::TTimeZoneChange change; |
1055 change.iNewTimeZoneId = 0; |
1129 change.iNewTimeZoneId = 0; |
1056 change.iOldTimeZoneId = oldTzId; |
1130 change.iOldTimeZoneId = oldTzId; |
1057 |
1131 |
1058 TPckgBuf<NTzUpdate::TTimeZoneChange> changeBuf(change); |
1132 TPckgBuf<NTzUpdate::TTimeZoneChange> changeBuf(change); |
|
1133 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,PUBLISH_UPDATE_NOTIFICATION, TZCHANGE_NOTIFICATION, "CTzConfigAgent::SetUnknownTimeZoneTimeL:TTimeZoneChange Notification" ); |
|
1134 |
1059 RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ECurrentTimeZoneId, changeBuf); |
1135 RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ECurrentTimeZoneId, changeBuf); |
1060 |
1136 |
1061 iTzDataProvider->ReleaseTzRules(); |
1137 iTzDataProvider->ReleaseTzRules(); |
|
1138 |
|
1139 OstTraceDef1( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZCONFIGAGENT_SETUNKNOWNTIMEZONETIMEL_EXIT, "CTzConfigAgent::SetUnknownTimeZoneTimeL Exit;KErrNone=%d", KErrNone ); |
1062 |
1140 |
1063 return KErrNone; |
1141 return KErrNone; |
1064 } |
1142 } |
1065 |
1143 |
1066 /** |
1144 /** |
1174 { |
1252 { |
1175 TRAP_IGNORE(NotifyUserTzRulesChangeL(aChange)); |
1253 TRAP_IGNORE(NotifyUserTzRulesChangeL(aChange)); |
1176 } |
1254 } |
1177 void CTzConfigAgent::NotifyUserTzRulesChangeL(TTzUserDataChange aChange) |
1255 void CTzConfigAgent::NotifyUserTzRulesChangeL(TTzUserDataChange aChange) |
1178 { |
1256 { |
|
1257 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_NOTIFYUSERTZRULESCHANGEL_ENTRY, "CTzConfigAgent::NotifyUserTzRulesChangeL Entry;Operation=%u;Time zone Id=%u",aChange.iOperation , aChange.iTzId ); |
|
1258 |
1179 //Only interested when a user TZ rule is updated or deleted |
1259 //Only interested when a user TZ rule is updated or deleted |
1180 if (aChange.iOperation == ETzUserDataUpdated || aChange.iOperation == ETzUserDataDeleted) |
1260 if (aChange.iOperation == ETzUserDataUpdated || aChange.iOperation == ETzUserDataDeleted) |
1181 { |
1261 { |
1182 //Chached time zone (iOtherTzCache) should be cleaned off. |
1262 //Chached time zone (iOtherTzCache) should be cleaned off. |
1183 delete iOtherTzCache; |
1263 delete iOtherTzCache; |
1203 CleanupStack::PushL(tzid); |
1283 CleanupStack::PushL(tzid); |
1204 SetTimeZoneL(*tzid, static_cast<TAny*>(this), ETrue, ETrue); |
1284 SetTimeZoneL(*tzid, static_cast<TAny*>(this), ETrue, ETrue); |
1205 CleanupStack::PopAndDestroy(tzid); |
1285 CleanupStack::PopAndDestroy(tzid); |
1206 } |
1286 } |
1207 } |
1287 } |
|
1288 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_NOTIFYUSERTZRULESCHANGEL_EXIT, "CTzConfigAgent::NotifyUserTzRulesChangeL Exit" ); |
|
1289 |
1208 } |
1290 } |
1209 |
1291 |
1210 void CTzConfigAgent::NotifyUserTzNamesChange(TTzUserDataChange /*aChange*/) |
1292 void CTzConfigAgent::NotifyUserTzNamesChange(TTzUserDataChange /*aChange*/) |
1211 {// There is no action needed when the names of a user defined time zone has been changed. |
1293 {// There is no action needed when the names of a user defined time zone has been changed. |
1212 } |
1294 } |
1249 iTzDataProvider->RestoreBeginningL(); |
1331 iTzDataProvider->RestoreBeginningL(); |
1250 } |
1332 } |
1251 |
1333 |
1252 void CTzConfigAgent::RestoreCompletedL(TInt aRestoreResult) |
1334 void CTzConfigAgent::RestoreCompletedL(TInt aRestoreResult) |
1253 { |
1335 { |
|
1336 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZCONFIGAGENT_RESTORECOMPLETEDL_ENTRY, "CTzConfigAgent::RestoreCompletedL Entry;aRestoreResult=%u", aRestoreResult ); |
|
1337 |
1254 if(aRestoreResult == KErrNone) |
1338 if(aRestoreResult == KErrNone) |
1255 { |
1339 { |
1256 //Both read only DB and user defined DB will refresh the data |
1340 //Both read only DB and user defined DB will refresh the data |
1257 iTzDataProvider->RestoreCompletedL(); |
1341 iTzDataProvider->RestoreCompletedL(); |
1258 |
1342 |
1293 |
1377 |
1294 //Publish the names change for user defined DB |
1378 //Publish the names change for user defined DB |
1295 NTzUpdate::TTzNamesChange namesChange; |
1379 NTzUpdate::TTzNamesChange namesChange; |
1296 namesChange.iUTCTimeOfNamesChange.UniversalTime(); |
1380 namesChange.iUTCTimeOfNamesChange.UniversalTime(); |
1297 TPckgBuf<NTzUpdate::TTzNamesChange> bufNames(namesChange); |
1381 TPckgBuf<NTzUpdate::TTzNamesChange> bufNames(namesChange); |
|
1382 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,PUBLISH_UPDATE_NOTIFICATION, TZNAMES_CHANGE_NOTIFICATION_4, "CTzConfigAgent::RestoreCompletedL: TzNames change notification" ); |
|
1383 |
1298 RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzNamesChange, bufNames); |
1384 RProperty::Set(NTzUpdate::KPropertyCategory, NTzUpdate::ETzNamesChange, bufNames); |
1299 } |
1385 } |
|
1386 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,PUBLISH_UPDATE_NOTIFICATION, CTZCONFIGAGENT_RESTORECOMPLETEDL_EXIT, "CTzConfigAgent::RestoreCompletedL Exit" ); |
|
1387 |
1300 } |
1388 } |
1301 //------------------------------------------------------------------------------------ |
1389 //------------------------------------------------------------------------------------ |
1302 CTZRulesCache::~CTZRulesCache() |
1390 CTZRulesCache::~CTZRulesCache() |
1303 { |
1391 { |
1304 delete iTimeZoneId; // time zone Id |
1392 delete iTimeZoneId; // time zone Id |
1314 User::Leave(KErrNotFound); |
1402 User::Leave(KErrNotFound); |
1315 } |
1403 } |
1316 |
1404 |
1317 const CTzRules& CTZRulesCache::doGetEncodedTimeZoneRulesL(TInt aStartYear, TInt aEndYear) |
1405 const CTzRules& CTZRulesCache::doGetEncodedTimeZoneRulesL(TInt aStartYear, TInt aEndYear) |
1318 { |
1406 { |
|
1407 OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZRULESCACHE_DOGETENCODEDTIMEZONERULESL_ENTRY, "CTZRulesCache::doGetEncodedTimeZoneRulesL Entry;aStartYear=%d;aEndYear=%d", aStartYear, aEndYear ); |
|
1408 |
1319 CTzDataProvider& tzDataProvider = iTimeZoneConfigAgent.TzDataProvider(); |
1409 CTzDataProvider& tzDataProvider = iTimeZoneConfigAgent.TzDataProvider(); |
1320 |
1410 |
1321 CTzRules* newRules = CTzRules::NewL(aStartYear, aEndYear); |
1411 CTzRules* newRules = CTzRules::NewL(aStartYear, aEndYear); |
1322 CleanupStack::PushL(newRules); |
1412 CleanupStack::PushL(newRules); |
1323 |
1413 |
1327 CleanupStack::Pop(newRules); |
1417 CleanupStack::Pop(newRules); |
1328 |
1418 |
1329 // replace current cached rules |
1419 // replace current cached rules |
1330 delete iEncodedRules; |
1420 delete iEncodedRules; |
1331 iEncodedRules = newRules; |
1421 iEncodedRules = newRules; |
|
1422 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZRULESCACHE_DOGETENCODEDTIMEZONERULESL_EXIT, "CTZRulesCache::doGetEncodedTimeZoneRulesL Exit" ); |
|
1423 |
1332 |
1424 |
1333 return *iEncodedRules; |
1425 return *iEncodedRules; |
1334 } |
1426 } |
1335 |
1427 |
1336 void CTZRulesCache::doGetActualisedTimeZoneRulesL(const TTime& aTime) |
1428 void CTZRulesCache::doGetActualisedTimeZoneRulesL(const TTime& aTime) |
1337 { |
1429 { |
|
1430 OstTraceDefExt5(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZRULESCACHE_DOGETACTUALISEDTIMEZONERULESL_ENTRY, "CTZRulesCache::doGetActualisedTimeZoneRulesL Entry;YY=%d;MM=%d;DD=%d;HH=%d;MIN=%d", aTime.DateTime().Year(),aTime.DateTime().Month(),aTime.DateTime().Day(),aTime.DateTime().Hour(),aTime.DateTime().Minute() ); |
|
1431 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZRULESCACHE_DOGETACTUALISEDTIMEZONERULESL_PARAM, "Parameters..;SS=%d",aTime.DateTime().Second()); |
|
1432 |
1338 TDateTime dateTime(aTime.DateTime() ); |
1433 TDateTime dateTime(aTime.DateTime() ); |
1339 |
1434 |
1340 // At least we need the rule for the year preceeding the converted time |
1435 // At least we need the rule for the year preceeding the converted time |
1341 // in order to convert the time to use it to find the correct rule. (Sounds roundabout!) |
1436 // in order to convert the time to use it to find the correct rule. (Sounds roundabout!) |
1342 // hence the extra one added to the cache limit |
1437 // hence the extra one added to the cache limit |
1366 CleanupStack::Pop(newRules); |
1461 CleanupStack::Pop(newRules); |
1367 |
1462 |
1368 // replace current cached rules |
1463 // replace current cached rules |
1369 delete iActualisedRules; |
1464 delete iActualisedRules; |
1370 iActualisedRules = newRules; |
1465 iActualisedRules = newRules; |
|
1466 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZRULESCACHE_DOGETACTUALISEDTIMEZONERULESL_EXIT, "CTZRulesCache::doGetActualisedTimeZoneRulesL Exit" ); |
|
1467 |
1371 } |
1468 } |
1372 |
1469 |
1373 void CTZRulesCache::ConstructL(const CTzId& aTimeZoneId, const TTime& aTime) |
1470 void CTZRulesCache::ConstructL(const CTzId& aTimeZoneId, const TTime& aTime) |
1374 { |
1471 { |
1375 if (aTimeZoneId.TimeZoneNumericID() != KUnknownTZId) |
1472 if (aTimeZoneId.TimeZoneNumericID() != KUnknownTZId) |
1434 return *iEncodedRules; |
1531 return *iEncodedRules; |
1435 } |
1532 } |
1436 |
1533 |
1437 TInt CTZRulesCache::GetEncodedTimeZoneRulesSizeL(const TTime& aStartTime, const TTime& aEndTime, TTzTimeReference /*aTimeRef */) |
1534 TInt CTZRulesCache::GetEncodedTimeZoneRulesSizeL(const TTime& aStartTime, const TTime& aEndTime, TTzTimeReference /*aTimeRef */) |
1438 { |
1535 { |
|
1536 |
1439 // fetch a new set of rules from the data provider if the range of the rules in iEncodedRules does not |
1537 // fetch a new set of rules from the data provider if the range of the rules in iEncodedRules does not |
1440 // contain both aStartTime and aEndTime |
1538 // contain both aStartTime and aEndTime |
1441 if ( |
1539 if ( |
1442 (iTimeZoneId->TimeZoneNumericID() != KUnknownTZId) |
1540 (iTimeZoneId->TimeZoneNumericID() != KUnknownTZId) |
1443 && |
1541 && |
1459 } |
1557 } |
1460 } |
1558 } |
1461 |
1559 |
1462 CVTzActualisedRules& CTZRulesCache::GetTimeZoneRulesL(const TTime& aTime,TTzTimeReference aTimerRef) |
1560 CVTzActualisedRules& CTZRulesCache::GetTimeZoneRulesL(const TTime& aTime,TTzTimeReference aTimerRef) |
1463 { |
1561 { |
|
1562 |
1464 if ((iTimeZoneId->TimeZoneNumericID() != KUnknownTZId) |
1563 if ((iTimeZoneId->TimeZoneNumericID() != KUnknownTZId) |
1465 && (!(RuleApplies(*iActualisedRules, aTime, aTimerRef)))) |
1564 && (!(RuleApplies(*iActualisedRules, aTime, aTimerRef)))) |
1466 { |
1565 { |
1467 doGetActualisedTimeZoneRulesL(aTime); |
1566 doGetActualisedTimeZoneRulesL(aTime); |
1468 } |
1567 } |
1473 Tests if the period covered by the cached rules applies to the supplied time. |
1572 Tests if the period covered by the cached rules applies to the supplied time. |
1474 */ |
1573 */ |
1475 TBool CTZRulesCache::RuleApplies(CVTzActualisedRules& actRules, |
1574 TBool CTZRulesCache::RuleApplies(CVTzActualisedRules& actRules, |
1476 const TTime& aTime, TTzTimeReference aTimerRef) const |
1575 const TTime& aTime, TTzTimeReference aTimerRef) const |
1477 { |
1576 { |
|
1577 OstTraceDefExt5( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZRULESCACHE_RULEAPPLIES_ENTRY, "CTZRulesCache::RuleApplies Entry;actRules Start year=%d;actRules End year=%d;aTime:YY=%d;aTime:MM=%d;aTime:DD=%d", actRules.StartYear(), actRules.EndYear(),aTime.DateTime().Year(),aTime.DateTime().Month(),aTime.DateTime().Day() ); |
|
1578 OstTraceDefExt4(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZRULESCACHE_RULEAPPLIES_ENTRY_PARAM, "Parametere cont..;aTime:Hours=%d;aTime:Min=%d;aTime:Sec=%d;aTimerRef=%u",aTime.DateTime().Hour(), aTime.DateTime().Minute(), aTime.DateTime().Second(), aTimerRef ); |
|
1579 |
1478 TInt startYear = actRules.StartYear(); |
1580 TInt startYear = actRules.StartYear(); |
1479 TInt endYear = actRules.EndYear(); |
1581 TInt endYear = actRules.EndYear(); |
1480 |
1582 |
1481 TDateTime dateTime(aTime.DateTime()); |
1583 TDateTime dateTime(aTime.DateTime()); |
1482 |
1584 |
1506 endYear++; |
1608 endYear++; |
1507 } |
1609 } |
1508 |
1610 |
1509 const TTime KStart(TDateTime(startYear, EJanuary, 0, 0, 0, 0, 0)); |
1611 const TTime KStart(TDateTime(startYear, EJanuary, 0, 0, 0, 0, 0)); |
1510 const TTime KEnd(TDateTime(endYear, EJanuary, 0, 0, 0, 0, 0)); |
1612 const TTime KEnd(TDateTime(endYear, EJanuary, 0, 0, 0, 0, 0)); |
|
1613 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZRULESCACHE_RULEAPPLIES_EXIT, "CTZRulesCache::RuleApplies Exit" ); |
|
1614 |
1511 return ((aTime >= KStart) && (aTime < KEnd)); |
1615 return ((aTime >= KStart) && (aTime < KEnd)); |
1512 } |
1616 } |
1513 |
1617 |
1514 //------------------------------------------------------------------------------------ |
1618 //------------------------------------------------------------------------------------ |
1515 // |
1619 // |