diff -r 8d692d9f828f -r 50974a8b132e serviceproviders/sapi_calendar/calendarservice/src/addentry.cpp --- a/serviceproviders/sapi_calendar/calendarservice/src/addentry.cpp Fri Nov 06 13:05:00 2009 +0200 +++ b/serviceproviders/sapi_calendar/calendarservice/src/addentry.cpp Tue Nov 24 08:56:33 2009 +0200 @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -525,14 +525,38 @@ User::Leave( KErrNotSupported ); } - TDateTime stTime; - stTime = aEntry->StartTimeL().TimeUtcL().DateTime(); - alTime.MinutesFrom( stTime, minutes );// calculate the offset between alarm time and start time - CCalAlarm* alarm = CCalAlarm::NewL(); - CleanupStack::PushL( alarm ); - alarm->SetTimeOffset(-minutes.Int()); - aEntry->SetAlarmL(alarm); // set the alarm for the entry - CleanupStack::PopAndDestroy( alarm ); + if( aEntry->EntryTypeL() != CCalEntry::ETodo ) + { + TDateTime stTime; + stTime = aEntry->StartTimeL().TimeUtcL().DateTime(); + alTime.MinutesFrom( stTime, minutes );// calculate the offset between alarm time and start time + CCalAlarm* alarm = CCalAlarm::NewL(); + CleanupStack::PushL( alarm ); + alarm->SetTimeOffset(-minutes.Int()); + aEntry->SetAlarmL(alarm); // set the alarm for the entry + CleanupStack::PopAndDestroy( alarm ); + } + else + { + TTime endTime; + endTime = aEntry->EndTimeL().TimeUtcL(); + if ( endTime != Time::NullTTime() ) + { + alTime.MinutesFrom( endTime, minutes );// calculate the offset between alarm time and start time + if(minutes.Int() < 0 ) + { + CCalAlarm* alarm = CCalAlarm::NewL(); + CleanupStack::PushL( alarm ); + alarm->SetTimeOffset(-minutes.Int()); + aEntry->SetAlarmL(alarm); // set the alarm for the entry + CleanupStack::PopAndDestroy( alarm ); + } + else + { + User::Leave( KErrNotSupported ); + } + } + } } }