diff -r 356f28cd5ca0 -r ed599363c2d7 calendarui/editors/src/CalenEditorDataHandler.cpp --- a/calendarui/editors/src/CalenEditorDataHandler.cpp Wed Sep 15 12:11:35 2010 +0300 +++ b/calendarui/editors/src/CalenEditorDataHandler.cpp Wed Oct 13 14:30:35 2010 +0300 @@ -30,7 +30,6 @@ #include #include // TCalenInstanceId #include -#include // User includes #include "CalenEditorDataHandler.h" @@ -43,7 +42,6 @@ #include "calenattachmentmodel.h" #include "calenunifiededitor.h" #include "calendarui_debug.h" -#include "koreanlunardateutil.h" // Constants #define KNoOfDaysInWeek 7 @@ -148,11 +146,7 @@ iInstanceId = iServices.Context().InstanceId(); } - // Sets up TLS, must be done before FeatureManager is used. - FeatureManager::InitializeLibL(); - // Used in destructor. - iFeatMgrInitialized = ETrue; - + TRACE_EXIT_POINT; } @@ -194,15 +188,7 @@ delete iOriginal; delete iEdited; - - - // Do not call UnInitializeLib() if InitalizeLib() leaves. - if ( iFeatMgrInitialized ) - { - // Frees the TLS. Must be done after FeatureManager is used. - FeatureManager::UnInitializeLib(); - } - + TRACE_EXIT_POINT; } @@ -345,8 +331,7 @@ IsCalendarEditedL() || IsAttachmentExists() || IsEventTypeEdited() || - AllDayFieldEdited() || - LunarFieldEdited() ); + AllDayFieldEdited() ); } // --------------------------------------------------------------------------- @@ -428,218 +413,196 @@ // Repeat rule has to be modified in both cases if ( isNew || IsStartDateTimeEdited() || IsRepeatRuleEdited() ) { - if ( FeatureManager::FeatureSupported( KFeatureIdKorean ) && - Edited().EntryType() == CCalEntry::EAnniv && - ( Edited().CalendarType() == ELunar || Edited().CalendarType() == ELunarLeap) ) - { /* Lunar entries need special repeating dates */ - CKoreanLunarDateUtil* dateUtil = CKoreanLunarDateUtil::NewLC(&iServices); - RArray repeatDateList; - CleanupClosePushL( repeatDateList ); - - /* Clear previous repeat rules */ + + if ( aRepeatTarget == CalCommon::EThisOnly) + { iEntry.ClearRepeatingPropertiesL(); - TRAPD( err, dateUtil->GetLunarYearlyRepeatsL( repeatDateList, Edited().StartDateTime().DateTime(), UseFloatingTimeL() ) ); - - if( err == KErrNone ) - { - iEntry.SetRDatesL( repeatDateList ); - } - - /* Pop and destroy repeatDateList and dateUtil */ - CleanupStack::PopAndDestroy(2); } - else + else if ( Edited().IsRepeating() ) { - if ( aRepeatTarget == CalCommon::EThisOnly) + // If we're an RDate (with repeat type ERepeatOther), don't try to set an RRule, + // but don't clear the repeat properties either. + if( Edited().RepeatType() != ERepeatOther ) { - iEntry.ClearRepeatingPropertiesL(); + TCalRRule rrule; + + CalculateRepeatRuleL( Edited().StartDateTime(), + Edited().RepeatType(), + Edited().RepeatUntilDateTime(), + rrule ); + + iEntry.SetRRuleL( rrule ); + + // As there should not be any rdates, remove any that are + // still present + RArray emptyList; + CleanupClosePushL( emptyList ); + iEntry.SetRDatesL( emptyList ); + CleanupStack::PopAndDestroy(); // emptyList } - else if ( Edited().IsRepeating() ) + else { - // If we're an RDate (with repeat type ERepeatOther), don't try to set an RRule, - // but don't clear the repeat properties either. - if( Edited().RepeatType() != ERepeatOther ) + // The repeat type is ERepeatOther, therefore as + // it is impossible to create an entry of type + // ERepeat other using the editor either the repeat until + // date or the start date must have been changed + + // The start date/time has changed, in order for the + // series to maintain its pattern, any rDates and if + // present rRule are moved by the same offset + // The repeat type is ERepeatOther, so check if we have any rdates + RArray rDateList; + CleanupClosePushL( rDateList ); + iEntry.GetRDatesL( rDateList ); + TInt count = rDateList.Count(); + + if ( count == 0 ) { + // There are no rdates so the new until and start date can be applied + // directly. TCalRRule rrule; - + CalculateRepeatRuleL( Edited().StartDateTime(), - Edited().RepeatType(), - Edited().RepeatUntilDateTime(), - rrule ); - + Edited().RepeatType(), + Edited().RepeatUntilDateTime(), + rrule ); + iEntry.SetRRuleL( rrule ); - - // As there should not be any rdates, remove any that are - // still present - RArray emptyList; - CleanupClosePushL( emptyList ); - iEntry.SetRDatesL( emptyList ); - CleanupStack::PopAndDestroy(); // emptyList } else { - // The repeat type is ERepeatOther, therefore as - // it is impossible to create an entry of type - // ERepeat other using the editor either the repeat until - // date or the start date must have been changed - - // The start date/time has changed, in order for the - // series to maintain its pattern, any rDates and if - // present rRule are moved by the same offset - // The repeat type is ERepeatOther, so check if we have any rdates - RArray rDateList; - CleanupClosePushL( rDateList ); - iEntry.GetRDatesL( rDateList ); - TInt count = rDateList.Count(); - - if ( count == 0 ) + // There are rDates which need to be checked. + if ( IsStartDateTimeEdited() ) { - // There are no rdates so the new until and start date can be applied - // directly. - TCalRRule rrule; - - CalculateRepeatRuleL( Edited().StartDateTime(), - Edited().RepeatType(), - Edited().RepeatUntilDateTime(), - rrule ); - - iEntry.SetRRuleL( rrule ); + // Need to shift any rdates + TTime editedStart = iEdited->StartDateTime(); + TTime origStart = iOriginal->StartDateTime(); + TTimeIntervalMicroSeconds offSet = editedStart.MicroSecondsFrom( origStart ); + for ( TInt index = 0; index < count; index++ ) + { + TCalTime& rDateTime = rDateList[ index ]; + TTime shiftedTime = rDateTime.TimeUtcL(); + TDateTime before = shiftedTime.DateTime(); + shiftedTime += offSet; + TDateTime after = shiftedTime.DateTime(); + rDateTime.SetTimeUtcL( shiftedTime ); + } } - else + + // Check and fix the rDates and rRules match the + // repeat until date and time. + TTime untilTime = Edited().RepeatUntilDateTime(); + + // Remove any rdates that are after the the repeat until date + TInt count = rDateList.Count(); + if ( count > 0 ) { - // There are rDates which need to be checked. - if ( IsStartDateTimeEdited() ) + TInt index = count - 1; + do { - // Need to shift any rdates - TTime editedStart = iEdited->StartDateTime(); - TTime origStart = iOriginal->StartDateTime(); - TTimeIntervalMicroSeconds offSet = editedStart.MicroSecondsFrom( origStart ); - for ( TInt index = 0; index < count; index++ ) + TTime lastRDate = CalenDateUtils::BeginningOfDay( rDateList[ index ].TimeLocalL() ); + TDateTime before = lastRDate.DateTime(); + if ( lastRDate > untilTime ) { - TCalTime& rDateTime = rDateList[ index ]; - TTime shiftedTime = rDateTime.TimeUtcL(); - TDateTime before = shiftedTime.DateTime(); - shiftedTime += offSet; - TDateTime after = shiftedTime.DateTime(); - rDateTime.SetTimeUtcL( shiftedTime ); + rDateList.Remove( index-- ); + } + else + { + index = KErrNotFound; } - } - - // Check and fix the rDates and rRules match the - // repeat until date and time. - TTime untilTime = Edited().RepeatUntilDateTime(); - - // Remove any rdates that are after the the repeat until date - TInt count = rDateList.Count(); + } while ( index != KErrNotFound ); + } + + // Need to check if the end date of the + // rrule needs adjusting if it exists. + TCalRRule rRule; + if ( iEntry.GetRRuleL( rRule ) ) + { + count = rDateList.Count(); if ( count > 0 ) { - TInt index = count - 1; - do - { - TTime lastRDate = CalenDateUtils::BeginningOfDay( rDateList[ index ].TimeLocalL() ); - TDateTime before = lastRDate.DateTime(); - if ( lastRDate > untilTime ) + // There still exists some rdates, so only need to trim + // the rrule if it exists + TTime lastRDate = CalenDateUtils::BeginningOfDay( rDateList[ count - 1 ].TimeLocalL() ); + const TTime& origUntilDate = Original().RepeatUntilDateTime(); + TTime startDT = rRule.DtStart().TimeLocalL(); + + if ( lastRDate <= origUntilDate && startDT > lastRDate ) + { + if ( startDT < untilTime) { - rDateList.Remove( index-- ); - } - else - { - index = KErrNotFound; + if( origUntilDate != untilTime) + { + ApplyUntilDateToRRuleL( rRule, untilTime); + iEntry.SetRRuleL( rRule ); + } } - } while ( index != KErrNotFound ); - } - - // Need to check if the end date of the - // rrule needs adjusting if it exists. - TCalRRule rRule; - if ( iEntry.GetRRuleL( rRule ) ) - { - count = rDateList.Count(); - if ( count > 0 ) - { - // There still exists some rdates, so only need to trim - // the rrule if it exists - TTime lastRDate = CalenDateUtils::BeginningOfDay( rDateList[ count - 1 ].TimeLocalL() ); - const TTime& origUntilDate = Original().RepeatUntilDateTime(); - TTime startDT = rRule.DtStart().TimeLocalL(); - - if ( lastRDate <= origUntilDate && startDT > lastRDate ) - { - if ( startDT < untilTime) - { - if( origUntilDate != untilTime) - { - ApplyUntilDateToRRuleL( rRule, untilTime); - iEntry.SetRRuleL( rRule ); - } - } - else + else + { + // The repeat start is after the until date + // so remove any repeat information. + iEntry.ClearRepeatingPropertiesL(); + + // If the entry date has been moved past the until + // date, need to swap the an rDate for the entry. + TTime startTime = iEntry.StartTimeL().TimeLocalL(); + + if ( startTime > untilTime ) { - // The repeat start is after the until date - // so remove any repeat information. - iEntry.ClearRepeatingPropertiesL(); + // Find the duration of the entry + TTime endTime = iEntry.EndTimeL().TimeLocalL(); + TTimeIntervalMinutes duration; + //startTime.MinutesFrom( endTime, duration );// for bug: CMCA-745CZ4 + endTime.MinutesFrom( startTime, duration ); - // If the entry date has been moved past the until - // date, need to swap the an rDate for the entry. - TTime startTime = iEntry.StartTimeL().TimeLocalL(); - - if ( startTime > untilTime ) + // Choose the first rDate as the new start time + TCalTime newStartTime = rDateList[ 0 ]; + endTime = newStartTime.TimeLocalL() + duration; + + // FIXME. + // If there is only one rDate left, the agenda model + // will crash if it is deleted. + if ( count != 0 ) { - // Find the duration of the entry - TTime endTime = iEntry.EndTimeL().TimeLocalL(); - TTimeIntervalMinutes duration; - //startTime.MinutesFrom( endTime, duration );// for bug: CMCA-745CZ4 - endTime.MinutesFrom( startTime, duration ); - - // Choose the first rDate as the new start time - TCalTime newStartTime = rDateList[ 0 ]; - endTime = newStartTime.TimeLocalL() + duration; - - // FIXME. - // If there is only one rDate left, the agenda model - // will crash if it is deleted. - if ( count != 0 ) - { - rDateList.Remove( 0 ); - } - - TCalTime newEndTime; - if ( UseFloatingTimeL() ) - { - newEndTime.SetTimeLocalFloatingL( endTime ); - } - else - { - newEndTime.SetTimeLocalL( endTime ); - } - - iEntry.SetStartAndEndTimeL( newStartTime, newEndTime ); - } - } + rDateList.Remove( 0 ); + } + + TCalTime newEndTime; + if ( UseFloatingTimeL() ) + { + newEndTime.SetTimeLocalFloatingL( endTime ); + } + else + { + newEndTime.SetTimeLocalL( endTime ); + } + + iEntry.SetStartAndEndTimeL( newStartTime, newEndTime ); + } } } } - - iEntry.SetRDatesL( rDateList ); } - - CleanupStack::PopAndDestroy(); // rDateList + + iEntry.SetRDatesL( rDateList ); } + + CleanupStack::PopAndDestroy(); // rDateList } - else - { - iEntry.ClearRepeatingPropertiesL(); - - // FIXME As the entry is supposedly not repeating - // any rDates should be removed. Unforunately this - // is not possible at the moment because removing the - // rdates will cause the agenda model to panic - // - // RArray emptyList; - // CleanupClosePushL( emptyList ); - // iEntry.SetRDatesL( emptyList ); - // CleanupStack::PopAndDestroy(); // emptyList - } + } + else + { + iEntry.ClearRepeatingPropertiesL(); + + // FIXME As the entry is supposedly not repeating + // any rDates should be removed. Unforunately this + // is not possible at the moment because removing the + // rdates will cause the agenda model to panic + // + // RArray emptyList; + // CleanupClosePushL( emptyList ); + // iEntry.SetRDatesL( emptyList ); + // CleanupStack::PopAndDestroy(); // emptyList } } @@ -672,10 +635,7 @@ // If edit alarm of repeating entry, we have to nudge start // time to instance date - - if ( isRepeating && aRepeatTarget == CalCommon::EThisAndAll - || Edited().EntryType() == CCalEntry::EAnniv && Edited().CalendarType() != ESolar ) - // this is lunar anniv + if ( isRepeating && aRepeatTarget == CalCommon::EThisAndAll ) { // nudge to instance date; TTime instanceDate = iInstanceDateTime.TimeLocalL(); @@ -732,11 +692,6 @@ iEntry.SetPriorityL( priority ); } - if (FeatureManager::FeatureSupported( KFeatureIdKorean )) - { - iEntry.SetUserInt32L( (TUint32)Edited().CalendarType() ); - } - if ( isNew ) { CCalEntry::TReplicationStatus status = CCalEntry::EOpen; @@ -757,15 +712,14 @@ } iEntry.SetReplicationStatusL( status ); } - + /** * S60 settings for new entries */ if ( IsCreatingNew() ) { - - if ( Edited().EntryType() == CCalEntry::EAnniv && Edited().CalendarType() == ESolar) - { /* Lunar entries have different repeating */ + if ( Edited().EntryType() == CCalEntry::EAnniv ) + { TCalRRule rrule( TCalRRule::EYearly ); rrule.SetDtStart( iEntry.StartTimeL() ); rrule.SetInterval( 1 ); @@ -1491,17 +1445,6 @@ TRACE_ENTRY_POINT; TError error = EFormErrNone; - - if (FeatureManager::FeatureSupported( KFeatureIdKorean )) - { - if( Edited().CalendarType() == ELunar || - Edited().CalendarType() == ELunarLeap ) - { /* Lunar entries have alarm as offset - and can't thus be erroneous */ - return error; - } - } - // If alarm not active, no check if ( Edited().IsAlarmActivated() ) { @@ -2215,24 +2158,6 @@ return fieldModified; } -TBool CCalenEditorDataHandler::LunarFieldEdited() - { - TRACE_ENTRY_POINT; - TBool fieldModified = EFalse; - - if (FeatureManager::FeatureSupported( KFeatureIdKorean )) - { - if( iOriginal->CalendarType() != iEdited->CalendarType() ) - { - fieldModified = ETrue; - } - } - - TRACE_EXIT_POINT; - return fieldModified; - } - - // ----------------------------------------------------------------------------- // CCalenEditorDataHandler::SetDefaultAlarmDateTimeL // Sets the alarm to the default value. This function is called after the user