1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2004-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". |
306 { |
311 { |
307 } |
312 } |
308 |
313 |
309 CTzDbZone* CTzDbRegion::FindZoneL(TUint aCityNameReference) |
314 CTzDbZone* CTzDbRegion::FindZoneL(TUint aCityNameReference) |
310 { |
315 { |
|
316 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBREGION_FINDZONEL_ENTRY, "CTzDbRegion::FindZoneL Entry;aCityNameReference=%u", aCityNameReference ); |
|
317 |
311 TTzRegionalZoneIndex* zoneIndex = const_cast<TTzRegionalZoneIndex*>(&iReadOnlyTzDb.GetTRegionalZoneIndex(iPersistedEntity.iOffsetToRegionalZoneIndex)); |
318 TTzRegionalZoneIndex* zoneIndex = const_cast<TTzRegionalZoneIndex*>(&iReadOnlyTzDb.GetTRegionalZoneIndex(iPersistedEntity.iOffsetToRegionalZoneIndex)); |
312 const TInt KZoneCount = zoneIndex->iNumberOfZones; |
319 const TInt KZoneCount = zoneIndex->iNumberOfZones; |
313 TTzZone* tzone(NULL); |
320 TTzZone* tzone(NULL); |
314 for (TInt i = 0; i < KZoneCount; i++) |
321 for (TInt i = 0; i < KZoneCount; i++) |
315 { |
322 { |
319 return CTzDbZone::NewL(iReadOnlyTzDb,*tzone); |
326 return CTzDbZone::NewL(iReadOnlyTzDb,*tzone); |
320 } |
327 } |
321 } |
328 } |
322 |
329 |
323 // if it gets here, it means that the zone has not been found |
330 // if it gets here, it means that the zone has not been found |
|
331 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBREGION_FINDZONEL_EXIT, "CTzDbRegion::FindZoneL Exit" ); |
|
332 |
324 return NULL; |
333 return NULL; |
325 } |
334 } |
326 |
335 |
327 CTzDbZone* CTzDbRegion::FindZoneL(const TDesC8& aCityName) |
336 CTzDbZone* CTzDbRegion::FindZoneL(const TDesC8& aCityName) |
328 { |
337 { |
|
338 OstTraceDefExt1( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZDBREGION_FINDZONEL_ENTRY2, "CTzDbRegion::FindZoneL Entry;aCityName=%s", aCityName ); |
|
339 |
329 TTzZone* tzone(NULL); |
340 TTzZone* tzone(NULL); |
330 TTzRegionalZoneIndex* zoneIndex = const_cast<TTzRegionalZoneIndex*>(&iReadOnlyTzDb.GetTRegionalZoneIndex(iPersistedEntity.iOffsetToRegionalZoneIndex)); |
341 TTzRegionalZoneIndex* zoneIndex = const_cast<TTzRegionalZoneIndex*>(&iReadOnlyTzDb.GetTRegionalZoneIndex(iPersistedEntity.iOffsetToRegionalZoneIndex)); |
331 const TInt KZoneCount = zoneIndex->iNumberOfZones; |
342 const TInt KZoneCount = zoneIndex->iNumberOfZones; |
332 TPtrC8 name; |
343 TPtrC8 name; |
333 |
344 |
388 { |
400 { |
389 } |
401 } |
390 |
402 |
391 void CTzDbZone::GetRulesL(CTzRules& aRules) |
403 void CTzDbZone::GetRulesL(CTzRules& aRules) |
392 { |
404 { |
|
405 OstTraceDefExt2( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZDBZONE_GETRULESL_ENTRY, "CTzDbZone::GetRulesL Entry;Start year=%d;End year=%d",aRules.StartYear(), aRules.EndYear() ); |
|
406 |
|
407 |
393 // start and end years of interest |
408 // start and end years of interest |
394 TInt firstYearOfInterest = aRules.StartYear(); |
409 TInt firstYearOfInterest = aRules.StartYear(); |
395 TInt lastYearOfInterest = aRules.EndYear(); |
410 TInt lastYearOfInterest = aRules.EndYear(); |
396 |
411 |
397 // record last instant of end year, in order to see if we need to get another time alignment |
412 // record last instant of end year, in order to see if we need to get another time alignment |
470 startDateTime = startTime.DateTime(); |
485 startDateTime = startTime.DateTime(); |
471 } |
486 } |
472 } |
487 } |
473 } // if IsTimeInStdTimeAlignment(...) |
488 } // if IsTimeInStdTimeAlignment(...) |
474 } // for |
489 } // for |
|
490 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBZONE_GETRULESL_EXIT, "CTzDbZone::GetRulesL Exit" ); |
|
491 |
475 |
492 |
476 } |
493 } |
477 |
494 |
478 TBool CTzDbZone::IsTimeInStdTimeAlignment(const TTzStdTimeAlignment& aStdTa, TInt aYear, TInt aMonth, TInt aDay, TInt aHour, TInt aMinute, TTzTimeReference aTimeRef) |
495 TBool CTzDbZone::IsTimeInStdTimeAlignment(const TTzStdTimeAlignment& aStdTa, TInt aYear, TInt aMonth, TInt aDay, TInt aHour, TInt aMinute, TTzTimeReference aTimeRef) |
479 { |
496 { |
624 { |
641 { |
625 } |
642 } |
626 |
643 |
627 void CTzDbStdTimeAlignment::GetRulesL(CTzRules& aRules, const TDateTime& aStartDateTime, TDateTime& aEndDateTime) |
644 void CTzDbStdTimeAlignment::GetRulesL(CTzRules& aRules, const TDateTime& aStartDateTime, TDateTime& aEndDateTime) |
628 { |
645 { |
|
646 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBSTDTIMEALIGNMENT_GETRULESL_ENTRY, "CTzDbStdTimeAlignment::GetRulesL Entry" ); |
|
647 |
629 // get the ruleSet for this time alignment |
648 // get the ruleSet for this time alignment |
630 CTzDbRuleSet* ruleSet = iReadOnlyTzDb.GetRuleSetL(iPersistedEntity.iOffsetToRuleSet); |
649 CTzDbRuleSet* ruleSet = iReadOnlyTzDb.GetRuleSetL(iPersistedEntity.iOffsetToRuleSet); |
631 if (ruleSet) |
650 if (ruleSet) |
632 { |
651 { |
633 CleanupStack::PushL(ruleSet); // PUSH #1 - RULESET |
652 CleanupStack::PushL(ruleSet); // PUSH #1 - RULESET |
655 // the global rule collection |
674 // the global rule collection |
656 AddRulesToCollectionL(aRules,*newRules); |
675 AddRulesToCollectionL(aRules,*newRules); |
657 |
676 |
658 CleanupStack::PopAndDestroy(2, ruleSet); // POP #2,#1 - NEWRULES, RULESET |
677 CleanupStack::PopAndDestroy(2, ruleSet); // POP #2,#1 - NEWRULES, RULESET |
659 } |
678 } |
|
679 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBSTDTIMEALIGNMENT_GETRULESL_EXIT, "CTzDbStdTimeAlignment::GetRulesL Exit" ); |
|
680 |
660 } |
681 } |
661 |
682 |
662 void CTzDbStdTimeAlignment::AddRulesToCollectionL(CTzRules& aRuleCollection, CTzRules& aNewRules) |
683 void CTzDbStdTimeAlignment::AddRulesToCollectionL(CTzRules& aRuleCollection, CTzRules& aNewRules) |
663 { |
684 { |
|
685 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZDBSTDTIMEALIGNMENT_ADDRULESTOCOLLECTIONL_ENTRy, "CTzDbStdTimeAlignment::AddRulesToCollectionL Entry" ); |
|
686 |
664 TTzRule* tRule(NULL); |
687 TTzRule* tRule(NULL); |
665 TVTzActualisedRule tActRule; |
688 TVTzActualisedRule tActRule; |
666 TInt count = aNewRules.Count(); |
689 TInt count = aNewRules.Count(); |
667 for (TInt i = 0; i < count; i++) |
690 for (TInt i = 0; i < count; i++) |
668 { |
691 { |
971 // |
996 // |
972 // Gets the encoded rules for the current standard time alignment, between aStartDateTime and aEndDateTime |
997 // Gets the encoded rules for the current standard time alignment, between aStartDateTime and aEndDateTime |
973 // |
998 // |
974 void CTzDbRuleSet::GetRulesL(CTzRules& aTzRules, TInt aUtcOffset, const TDateTime& aStartDateTime, const TDateTime& aEndDateTime) const |
999 void CTzDbRuleSet::GetRulesL(CTzRules& aTzRules, TInt aUtcOffset, const TDateTime& aStartDateTime, const TDateTime& aEndDateTime) const |
975 { |
1000 { |
|
1001 |
|
1002 OstTraceDefExt5(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBRULESET_GETRULESL_ENTRY, "CTzDbRuleSet::GetRulesL Entry;aUtcOffset=%d;Startdate:Year=%d;Month=%d;Day=%d;Hours=%d", aUtcOffset,aStartDateTime.Year(),aStartDateTime.Month() , aStartDateTime.Day(),aStartDateTime.Hour() ); |
|
1003 OstTraceDefExt5(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBRULESET_GETRULESL_PARAM, "parameters cont..;Start date:Min=%d;Sec=%d;End Date:Year=%d;Month=%d;Day=%d", aStartDateTime.Minute(), aStartDateTime.Second(), aEndDateTime.Year(), aEndDateTime.Month(), aEndDateTime.Day() ); |
|
1004 OstTraceDefExt3( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZDBRULESET_GETRULESL_ENTRY_PARAM2, "parameters cont..;Hour=%d;Min=%d;Sec=%d", aEndDateTime.Hour(), aEndDateTime.Minute(), aEndDateTime.Second() ); |
|
1005 |
976 TInt startYear = aStartDateTime.Year(); |
1006 TInt startYear = aStartDateTime.Year(); |
977 // the last year we are interested in is the earliest of the following: |
1007 // the last year we are interested in is the earliest of the following: |
978 // 1) the last year of the CTzRules |
1008 // 1) the last year of the CTzRules |
979 // 2) the year of aEndDateTime (the end of the invoking std time alignment) |
1009 // 2) the year of aEndDateTime (the end of the invoking std time alignment) |
980 |
1010 |
998 // convert rule definitions (together with rule uses) to TTzRules and add them to aTzRules |
1028 // convert rule definitions (together with rule uses) to TTzRules and add them to aTzRules |
999 |
1029 |
1000 CompleteRulesAndAddToCollectionL(aTzRules,ruleDefs,ruleUses,aUtcOffset,initialLocalTimeOffset,aStartDateTime,endDateTime); |
1030 CompleteRulesAndAddToCollectionL(aTzRules,ruleDefs,ruleUses,aUtcOffset,initialLocalTimeOffset,aStartDateTime,endDateTime); |
1001 |
1031 |
1002 CleanupStack::PopAndDestroy(2,&ruleDefs); // POP #2,#1 - ruleUses, ruleDefs |
1032 CleanupStack::PopAndDestroy(2,&ruleDefs); // POP #2,#1 - ruleUses, ruleDefs |
|
1033 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBRULESET_GETRULESL_EXIT, "CTzDbRuleSet::GetRulesL Exit" ); |
|
1034 |
1003 } |
1035 } |
1004 |
1036 |
1005 TInt CTzDbRuleSet::GetLocalTimeOffsetAtEndOfYearL(TInt aYear, TInt aUtcOffset) const |
1037 TInt CTzDbRuleSet::GetLocalTimeOffsetAtEndOfYearL(TInt aYear, TInt aUtcOffset) const |
1006 { |
1038 { |
1007 RArray<TTzRuleDefinition*> ruleDefs; |
1039 RArray<TTzRuleDefinition*> ruleDefs; |
1032 const RArray<TTzRuleDefinition*>& aRuleDefs, |
1064 const RArray<TTzRuleDefinition*>& aRuleDefs, |
1033 const RArray<TTzRuleUse*>& aRuleUses, |
1065 const RArray<TTzRuleUse*>& aRuleUses, |
1034 TInt aUtcOffset, TInt aInitialLocalTimeOffset, |
1066 TInt aUtcOffset, TInt aInitialLocalTimeOffset, |
1035 TDateTime aStart, TDateTime aEnd) const |
1067 TDateTime aStart, TDateTime aEnd) const |
1036 { |
1068 { |
|
1069 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBRULESET_COMPLETERULESANDADDTOCOLLECTIONL_ENTRY, "CTzDbRuleSet::CompleteRulesAndAddToCollectionL Entry" ); |
|
1070 |
1037 TInt count = aRuleDefs.Count(); |
1071 TInt count = aRuleDefs.Count(); |
1038 if (count != aRuleUses.Count()) |
1072 if (count != aRuleUses.Count()) |
1039 { |
1073 { |
1040 User::Leave(KErrCorrupt); |
1074 User::Leave(KErrCorrupt); |
1041 } |
1075 } |
1118 timeReference, timeOfChange); |
1152 timeReference, timeOfChange); |
1119 |
1153 |
1120 aTzRules.AddRuleL(trule); |
1154 aTzRules.AddRuleL(trule); |
1121 |
1155 |
1122 } |
1156 } |
1123 } |
1157 } |
|
1158 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZDBRULESET_COMPLETERULESANDADDTOCOLLECTIONL_EXIT, "CTzDbRuleSet::CompleteRulesAndAddToCollectionL Exit" ); |
|
1159 |
1124 } |
1160 } |
1125 |
1161 |
1126 void CTzDbRuleSet::FetchRuleDefinitionsL(RArray<TTzRuleDefinition*>& aTzRuleDefinitions, RArray<TTzRuleUse*>& aTzRuleUses, TInt aStartYear, TInt aEndYear) const |
1162 void CTzDbRuleSet::FetchRuleDefinitionsL(RArray<TTzRuleDefinition*>& aTzRuleDefinitions, RArray<TTzRuleUse*>& aTzRuleUses, TInt aStartYear, TInt aEndYear) const |
1127 { |
1163 { |
1128 TInt ruleUseCount = iPersistedEntity.iNumberOfRuleUses; |
1164 TInt ruleUseCount = iPersistedEntity.iNumberOfRuleUses; |
1149 } |
1185 } |
1150 } |
1186 } |
1151 |
1187 |
1152 void CTzDbRuleSet::ActualiseRuleDefinitionsL(CVTzActualisedRules& aActualisedRules, const RArray<TTzRuleDefinition*>& aTzRuleDefinitions, const RArray<TTzRuleUse*>& aTzRuleUses, TInt aUtcOffset, const TDateTime& aStartDateTime, const TDateTime& aEndDateTime, const TVTzActualisedRule& aDefaultRule) const |
1188 void CTzDbRuleSet::ActualiseRuleDefinitionsL(CVTzActualisedRules& aActualisedRules, const RArray<TTzRuleDefinition*>& aTzRuleDefinitions, const RArray<TTzRuleUse*>& aTzRuleUses, TInt aUtcOffset, const TDateTime& aStartDateTime, const TDateTime& aEndDateTime, const TVTzActualisedRule& aDefaultRule) const |
1153 { |
1189 { |
|
1190 OstTraceDef0( OST_TRACE_CATEGORY_DEBUG,TRACE_FLOW_PARAM, CTZDBRULESET_ACTUALISERULEDEFINITIONSL_ENTRY, "CTzDbRuleSet::ActualiseRuleDefinitionsL Entry" ); |
|
1191 |
1154 TInt startYear = aStartDateTime.Year(); |
1192 TInt startYear = aStartDateTime.Year(); |
1155 TInt endYear = (aActualisedRules.EndYear() < (TUint)aEndDateTime.Year()) ? aActualisedRules.EndYear() : aEndDateTime.Year(); |
1193 TInt endYear = (aActualisedRules.EndYear() < (TUint)aEndDateTime.Year()) ? aActualisedRules.EndYear() : aEndDateTime.Year(); |
1156 TInt rulesAddedSoFar = 0; |
1194 TInt rulesAddedSoFar = 0; |
1157 TInt yearOfFirstRule = endYear; |
1195 TInt yearOfFirstRule = endYear; |
1158 TInt count = aTzRuleDefinitions.Count(); |
1196 TInt count = aTzRuleDefinitions.Count(); |
1188 // as time-of-change). This default rule will be added if no rule exists for the |
1226 // as time-of-change). This default rule will be added if no rule exists for the |
1189 // first year of the time alignment. |
1227 // first year of the time alignment. |
1190 if ( (rulesAddedSoFar == 0) || (yearOfFirstRule > startYear) ) |
1228 if ( (rulesAddedSoFar == 0) || (yearOfFirstRule > startYear) ) |
1191 { |
1229 { |
1192 aActualisedRules.AddRuleL(aDefaultRule); |
1230 aActualisedRules.AddRuleL(aDefaultRule); |
1193 } |
1231 } |
|
1232 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_FLOW_PARAM, CTZDBRULESET_ACTUALISERULEDEFINITIONSL_EXIT, "CTzDbRuleSet::ActualiseRuleDefinitionsL Exit" ); |
|
1233 |
1194 } |
1234 } |
1195 |
1235 |
1196 //============================================================================================ |
1236 //============================================================================================ |
1197 |
1237 |
1198 TInt CTzHelpers::Validate(const TTzRuleDefinition& aRuleDefinition) |
1238 TInt CTzHelpers::Validate(const TTzRuleDefinition& aRuleDefinition) |