meetingrequest/mrgui/src/cesmrmeetingtimevalidator.cpp
branchRCL_3
changeset 16 4ce476e64c59
parent 1 12c456ceeff2
child 24 b5fbb9b25d57
equal deleted inserted replaced
13:0396474f30f5 16:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    26 #include "cesmrglobalnote.h"
    26 #include "cesmrglobalnote.h"
    27 #include "mesmrfieldstorage.h"
    27 #include "mesmrfieldstorage.h"
    28 #include "mesmrcalentry.h"
    28 #include "mesmrcalentry.h"
    29 #include "mesmrmeetingrequestentry.h"
    29 #include "mesmrmeetingrequestentry.h"
    30 #include "mesmrfieldeventqueue.h"
    30 #include "mesmrfieldeventqueue.h"
       
    31 #include "mmrabsolutealarmcontroller.h"
    31 #include "cesmrgenericfieldevent.h"
    32 #include "cesmrgenericfieldevent.h"
       
    33 #include "cesmrrecurrenceinfoHandler.h"
    32 
    34 
    33 // Unnamed namespace for local definitions
    35 // Unnamed namespace for local definitions
    34 namespace { // codescanner::namespace
    36 namespace { // codescanner::namespace
    35 
    37 
    36 // Definition fom max possible time
    38 // Definition fom max possible time
   170         }
   172         }
   171     else if ( aTime > KMaxTTime )
   173     else if ( aTime > KMaxTTime )
   172         {
   174         {
   173         aTime = KMaxTTime;
   175         aTime = KMaxTTime;
   174         }
   176         }
   175 
   177     
   176     if ( aEditor.IsVisible() )
   178     aEditor.SetTime( aTime );
   177         {
       
   178         aEditor.SetTime( aTime );
       
   179         }
       
   180     }
   179     }
   181 
   180 
   182 /**
   181 /**
   183  * Sets date to editor. Date is checked and adjusted
   182  * Sets date to editor. Date is checked and adjusted
   184  * between min and max before setting
   183  * between min and max before setting
   196     else if ( aDate > KMaxTTime )
   195     else if ( aDate > KMaxTTime )
   197         {
   196         {
   198         aDate = KMaxTTime;
   197         aDate = KMaxTTime;
   199         }
   198         }
   200 
   199 
   201     if ( aEditor.IsVisible() )
   200     aEditor.SetDate( aDate );
   202         {
   201     }
   203         aEditor.SetDate( aDate );
   202 
   204         }
   203 /**
       
   204  * Compares two times and returns ETrue if they have same date components
       
   205  * @param aLhs Left hand side component
       
   206  * @param aRhs Right hand side component
       
   207  */
       
   208 TBool IsSameDay(
       
   209         const TDateTime& aLhs,
       
   210         const TDateTime& aRhs )
       
   211     {
       
   212     TBool retValue(EFalse);
       
   213 
       
   214     if ( aLhs.Day() == aRhs.Day() &&
       
   215          aLhs.Month() == aRhs.Month() &&
       
   216          aLhs.Year() == aRhs.Year()   )
       
   217         {
       
   218         retValue = ETrue;
       
   219         }
       
   220 
       
   221     return retValue;
   205     }
   222     }
   206 
   223 
   207 } // namespace
   224 } // namespace
   208 
   225 
   209 // ======== MEMBER FUNCTIONS ========
   226 // ======== MEMBER FUNCTIONS ========
   307             {
   324             {
   308             TDateTime startDt = startTime.DateTime();
   325             TDateTime startDt = startTime.DateTime();
   309             TDateTime endDt = endTime.DateTime();
   326             TDateTime endDt = endTime.DateTime();
   310 
   327 
   311             if ( startDt.Day() != endDt.Day() ||
   328             if ( startDt.Day() != endDt.Day() ||
   312                     startDt.Month() != endDt.Month() ||
   329                  startDt.Month() != endDt.Month() ||
   313                     startDt.Year() != endDt.Year() )
   330                  startDt.Year() != endDt.Year() )
   314                 {
   331                 {
   315                 error = MESMRFieldValidator::EErrorRecDifferetStartAndEnd;
   332                 error = MESMRFieldValidator::EErrorRecDifferetStartAndEnd;
   316                 }
   333                 }
   317 
   334 
   318             if ( KErrorNone == error &&
   335             if ( KErrorNone == error &&
   336                     static_cast<MESMRMeetingRequestEntry*>( iEntry );
   353                     static_cast<MESMRMeetingRequestEntry*>( iEntry );
   337             if ( mrEntry->IsRecurrentEventL() &&
   354             if ( mrEntry->IsRecurrentEventL() &&
   338                  MESMRCalEntry::EESMRThisOnly == mrEntry->RecurrenceModRule() )
   355                  MESMRCalEntry::EESMRThisOnly == mrEntry->RecurrenceModRule() )
   339                 {
   356                 {
   340                 TBool instanceAlreadyOnThisDay( 
   357                 TBool instanceAlreadyOnThisDay( 
   341                            mrEntry->AnyInstanceOnDayL(startTime, endTime) );
   358                            mrEntry->AnyInstancesBetweenTimePeriodL(
       
   359                         		   startTime, 
       
   360                         		   endTime ) );
   342                 
   361                 
   343                 if ( instanceAlreadyOnThisDay )
   362                 if ( instanceAlreadyOnThisDay )
   344                     {
   363                     {
   345                     error = MESMRFieldValidator::EErrorRescheduleInstance;
   364                     error = MESMRFieldValidator::EErrorRescheduleInstance;
   346                     }
   365                     }
   347                 }
   366                 }
   348             }         
   367             }
       
   368         
       
   369         if (  KErrorNone == error &&  
       
   370               MESMRCalEntry::EESMRCalEntryMeeting == iEntry->Type() )
       
   371             {
       
   372             // Check that is modified entry 
       
   373             if ( iEntry->IsRecurrentEventL() &&
       
   374                  MESMRCalEntry::EESMRThisOnly == iEntry->RecurrenceModRule() )
       
   375                 {
       
   376                 TBool instanceAlreadyOnThisDay( 
       
   377                            iEntry->AnyInstancesBetweenTimePeriodL(
       
   378                         		   startTime, 
       
   379                         		   endTime ) );
       
   380                 
       
   381                 if ( instanceAlreadyOnThisDay )
       
   382                     {
       
   383                     error = MESMRFieldValidator::EErrorRescheduleInstance;
       
   384                     }
       
   385                 }
       
   386             }  
       
   387         
       
   388         if (  KErrorNone == error &&  
       
   389               ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry->Type() || 
       
   390                 MESMRCalEntry::EESMRCalEntryMeeting == iEntry->Type() ) )
       
   391             {
       
   392             // Check that is modified entry 
       
   393             if ( iEntry->IsRecurrentEventL() &&
       
   394                  MESMRCalEntry::EESMRThisOnly == iEntry->RecurrenceModRule() )
       
   395                 {
       
   396                 error = ValidateEditedInstanceTimeL();
       
   397                 }
       
   398             }
   349         
   399         
   350         if ( KErrorNone == error && iAlldayEvent && iAlarmOnOff )
   400         if ( KErrorNone == error && iAlldayEvent && iAlarmOnOff )
   351             {
   401             {
   352             TTime alarmTime = AlarmDateTime();
   402             TTime alarmTime = AlarmDateTime();
   353             if ( alarmTime > startTime )
   403             if ( alarmTime > startTime )
   395             error = MESMRFieldValidator::EErrorRelativeAlarmInPast;
   445             error = MESMRFieldValidator::EErrorRelativeAlarmInPast;
   396             }
   446             }
   397 
   447 
   398         TTime until;
   448         TTime until;
   399         if ( iRecurrenceValue != ERecurrenceNot &&
   449         if ( iRecurrenceValue != ERecurrenceNot &&
   400              iRecurrenceValue != ERecurrenceUnknown &&
   450              iRecurrenceValue != ERecurrenceUnknown )
   401              iRecurrenceUntilDate && iRecurrenceUntilDate->IsVisible() )
       
   402             {
   451             {
   403             until = RecurrenceUntilTime();
   452             until = RecurrenceUntilTime();
   404 
   453 
   405             // Showing error note if is alarm in past, 
   454             // Showing error note if is alarm in past, 
   406             // when entry has recurrence
   455             // when entry has recurrence
   415         }
   464         }
   416     return error;
   465     return error;
   417     }
   466     }
   418 
   467 
   419 // ---------------------------------------------------------------------------
   468 // ---------------------------------------------------------------------------
       
   469 // CESMRMeetingTimeValidator::ValidateEditedInstanceTimeL
       
   470 // ---------------------------------------------------------------------------
       
   471 //
       
   472 MESMRFieldValidator::TESMRFieldValidatorError CESMRMeetingTimeValidator::ValidateEditedInstanceTimeL()
       
   473     { 
       
   474     CESMRRecurrenceInfoHandler* recurrenceHandler =
       
   475                 CESMRRecurrenceInfoHandler::NewLC( iEntry->Entry(), &iEntry->GetDBMgr() );
       
   476     TCalTime preStartTime;
       
   477     TCalTime preEndTime;
       
   478     TCalTime nextStartTime;
       
   479     TCalTime nextEndTime;
       
   480 
       
   481     CCalInstance* instance = iEntry->InstanceL();
       
   482     CleanupStack::PushL( instance );
       
   483     TTime instanceDateTime = instance->StartTimeL().TimeLocalL();
       
   484     CleanupStack::PopAndDestroy( instance );
       
   485 
       
   486     recurrenceHandler->GetPreviousInstanceTimeL( preStartTime, preEndTime, instanceDateTime );
       
   487     recurrenceHandler->GetNextInstanceTimeL( nextStartTime, nextEndTime, instanceDateTime );
       
   488 
       
   489     CleanupStack::PopAndDestroy( recurrenceHandler );
       
   490 
       
   491     const TTime editedStartDateTime( StartDateTime() );
       
   492     const TTime editedEndDateTime( EndDateTime() );  
       
   493 
       
   494     if( preStartTime.TimeLocalL() != Time::NullTTime() )
       
   495         {
       
   496         // Does the exception end on/after prevEnd?
       
   497         if( editedStartDateTime < preEndTime.TimeLocalL() )
       
   498             {
       
   499             // Does the exception start after prevStart?
       
   500             if( editedStartDateTime > preStartTime.TimeLocalL() )
       
   501                 {
       
   502                 return EErrorInstanceOverlapsExistingOne;
       
   503                 }
       
   504             else
       
   505                 {
       
   506                 // Does the exception finish after prevStart?
       
   507                 if( editedEndDateTime > preStartTime.TimeLocalL() )
       
   508                     {
       
   509                     return EErrorInstanceOverlapsExistingOne;
       
   510                     }
       
   511                 else
       
   512                     {
       
   513                     return EErrorInstanceOutOfSequence;
       
   514                     }
       
   515                 }
       
   516             }
       
   517 
       
   518         // Does the exception start on the same day as prevStart?
       
   519         if( IsSameDay( StartDateTime(), preStartTime.TimeLocalL().DateTime() ) )
       
   520             {
       
   521             return EErrorInstanceAlreadyExistsOnThisDay;
       
   522             }
       
   523         }
       
   524 
       
   525 
       
   526     if( nextStartTime.TimeLocalL() != Time::NullTTime() )
       
   527         {
       
   528         // Does the exception finish on/before nextStart?
       
   529         if( editedEndDateTime > nextStartTime.TimeLocalL() )
       
   530             {
       
   531             // Does the exception finish before nextFinish?
       
   532             if( editedEndDateTime < nextEndTime.TimeLocalL() )
       
   533                 {
       
   534                 return EErrorInstanceOverlapsExistingOne;
       
   535                 }
       
   536             else
       
   537                 {
       
   538                 // Does the exception start before nextFinish?
       
   539                 if( editedStartDateTime < nextEndTime.TimeLocalL() )
       
   540                     {
       
   541                     return EErrorInstanceOverlapsExistingOne;
       
   542                     }
       
   543                 else
       
   544                     {
       
   545                     return EErrorInstanceOutOfSequence;
       
   546                     }
       
   547                 }
       
   548             }
       
   549 
       
   550         // Does the exception start on the same day as nextStart?
       
   551         if( IsSameDay( StartDateTime(), nextStartTime.TimeLocalL().DateTime() ) )
       
   552             {
       
   553             return EErrorInstanceAlreadyExistsOnThisDay;
       
   554             }
       
   555         }
       
   556 
       
   557 
       
   558     // Does the series have any rdates
       
   559     RArray<TCalTime> rDateArray;
       
   560     CleanupClosePushL( rDateArray );
       
   561     iEntry->Entry().GetRDatesL( rDateArray );
       
   562     TInt rDateCount = rDateArray.Count();
       
   563 
       
   564     if ( rDateCount > 0 )
       
   565         {
       
   566         // If the series has rdates, check that the exception
       
   567         // does not overlap or start on the same day
       
   568         TTimeIntervalMinutes duration;
       
   569         editedStartDateTime.MinutesFrom( editedEndDateTime, duration );
       
   570 
       
   571         for ( TInt index = 0; index < rDateCount; index++ )
       
   572             {
       
   573             const TTime& rDate = rDateArray[ index ].TimeLocalL();
       
   574 
       
   575             if ( !IsSameDay( iEntry->Entry().StartTimeL().TimeLocalL().DateTime(), rDate.DateTime() ) )
       
   576                 {
       
   577                 // Does the exception start or end on the same day as a rdate.
       
   578                 if ( IsSameDay( StartDateTime(), rDate.DateTime() ) )
       
   579                     {
       
   580                     CleanupStack::PopAndDestroy(); // rDateArray
       
   581                     return EErrorInstanceAlreadyExistsOnThisDay;
       
   582                     }
       
   583 
       
   584                 // Does the exception overlap an rdate?
       
   585                 TTime rDateEnd = rDate + duration;
       
   586                 if ( editedEndDateTime > rDateEnd && editedStartDateTime < rDate )
       
   587                     {
       
   588                     CleanupStack::PopAndDestroy(); // rDateArray
       
   589                     return EErrorInstanceOverlapsExistingOne;
       
   590                     }
       
   591                 }
       
   592             }
       
   593         }
       
   594 
       
   595     CleanupStack::PopAndDestroy(); // rDateArray
       
   596     return EErrorNone;
       
   597     }
       
   598 
       
   599 // ---------------------------------------------------------------------------
   420 // CESMRMeetingTimeValidator::ReadValuesFromEntryL
   600 // CESMRMeetingTimeValidator::ReadValuesFromEntryL
   421 // ---------------------------------------------------------------------------
   601 // ---------------------------------------------------------------------------
   422 //
   602 //
   423 void CESMRMeetingTimeValidator::ReadValuesFromEntryL(
   603 void CESMRMeetingTimeValidator::ReadValuesFromEntryL(
   424         MESMRCalEntry& aEntry )
   604         MESMRCalEntry& aEntry )
   470         SetTimeToEditor( *iEndTime, end );
   650         SetTimeToEditor( *iEndTime, end );
   471         SetDateToEditor( *iEndDate, end );
   651         SetDateToEditor( *iEndDate, end );
   472 
   652 
   473         ReadAlarmFromEntryL( entry );
   653         ReadAlarmFromEntryL( entry );
   474         ReadRecurrenceFromEntryL( aEntry );
   654         ReadRecurrenceFromEntryL( aEntry );
   475 
   655         
   476         DrawEditorsDeferred();
   656         DrawEditorsDeferred();
       
   657         SendFieldChangeEventL( EESMRFieldStartDate );
   477         }
   658         }
   478     }
   659     }
   479 // ---------------------------------------------------------------------------
   660 // ---------------------------------------------------------------------------
   480 // CESMRMeetingTimeValidator::StoreValuesToEntryL
   661 // CESMRMeetingTimeValidator::StoreValuesToEntryL
   481 // ---------------------------------------------------------------------------
   662 // ---------------------------------------------------------------------------
   564             {
   745             {
   565             entry.SetAlarmL( NULL );
   746             entry.SetAlarmL( NULL );
   566             }
   747             }
   567         }
   748         }
   568 
   749 
       
   750 
   569     if ( ERecurrenceNot != iRecurrenceValue &&
   751     if ( ERecurrenceNot != iRecurrenceValue &&
   570          ERecurrenceUnknown != iRecurrenceValue )
   752          ERecurrenceUnknown != iRecurrenceValue )
   571         {
   753         {
   572         aEntry.SetRecurrenceL(
   754         aEntry.SetRecurrenceL(
   573                 iRecurrenceValue,
   755                 iRecurrenceValue,
   590 void CESMRMeetingTimeValidator::SetStartTimeFieldL(
   772 void CESMRMeetingTimeValidator::SetStartTimeFieldL(
   591         CEikTimeEditor& aStartTime )
   773         CEikTimeEditor& aStartTime )
   592     {
   774     {
   593     FUNC_LOG;
   775     FUNC_LOG;
   594     iStartTime = &aStartTime;
   776     iStartTime = &aStartTime;
       
   777     
       
   778     if ( Time::NullTTime() != iCurrentStartTime )
       
   779         {
       
   780         SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
   781         }
   595     }
   782     }
   596 
   783 
   597 // ---------------------------------------------------------------------------
   784 // ---------------------------------------------------------------------------
   598 // CESMRMeetingTimeValidator::SetEndTimeFieldL
   785 // CESMRMeetingTimeValidator::SetEndTimeFieldL
   599 // ---------------------------------------------------------------------------
   786 // ---------------------------------------------------------------------------
   601 void CESMRMeetingTimeValidator::SetEndTimeFieldL(
   788 void CESMRMeetingTimeValidator::SetEndTimeFieldL(
   602         CEikTimeEditor& aEndTime )
   789         CEikTimeEditor& aEndTime )
   603     {
   790     {
   604     FUNC_LOG;
   791     FUNC_LOG;
   605     iEndTime = &aEndTime;
   792     iEndTime = &aEndTime;
       
   793     
       
   794     if ( Time::NullTTime() != iCurrentEndTime )
       
   795         {
       
   796         SetTimeToEditor( *iEndTime, iCurrentEndTime );
       
   797         }    
   606     }
   798     }
   607 
   799 
   608 // ---------------------------------------------------------------------------
   800 // ---------------------------------------------------------------------------
   609 // CESMRMeetingTimeValidator::SetStartDateFieldL
   801 // CESMRMeetingTimeValidator::SetStartDateFieldL
   610 // ---------------------------------------------------------------------------
   802 // ---------------------------------------------------------------------------
   612 void CESMRMeetingTimeValidator::SetStartDateFieldL(
   804 void CESMRMeetingTimeValidator::SetStartDateFieldL(
   613         CEikDateEditor& aStartDate )
   805         CEikDateEditor& aStartDate )
   614     {
   806     {
   615     FUNC_LOG;
   807     FUNC_LOG;
   616     iStartDate = &aStartDate;
   808     iStartDate = &aStartDate;
       
   809     
       
   810     if ( Time::NullTTime() != iCurrentStartTime )
       
   811         {
       
   812         SetDateToEditor( *iStartDate, iCurrentStartTime );
       
   813         }    
   617     }
   814     }
   618 
   815 
   619 // ---------------------------------------------------------------------------
   816 // ---------------------------------------------------------------------------
   620 // CESMRMeetingTimeValidator::SetEndDateFieldL
   817 // CESMRMeetingTimeValidator::SetEndDateFieldL
   621 // ---------------------------------------------------------------------------
   818 // ---------------------------------------------------------------------------
   623 void CESMRMeetingTimeValidator::SetEndDateFieldL(
   820 void CESMRMeetingTimeValidator::SetEndDateFieldL(
   624         CEikDateEditor& aEndTime )
   821         CEikDateEditor& aEndTime )
   625     {
   822     {
   626     FUNC_LOG;
   823     FUNC_LOG;
   627     iEndDate = &aEndTime;
   824     iEndDate = &aEndTime;
       
   825     
       
   826     if ( Time::NullTTime() != iCurrentEndTime )
       
   827         {
       
   828         SetDateToEditor( *iEndDate, iCurrentEndTime );
       
   829         }    
   628     }
   830     }
   629 
   831 
   630 // ---------------------------------------------------------------------------
   832 // ---------------------------------------------------------------------------
   631 // CESMRMeetingTimeValidator::SetAlarmTimeFieldL
   833 // CESMRMeetingTimeValidator::SetAlarmTimeFieldL
   632 // ---------------------------------------------------------------------------
   834 // ---------------------------------------------------------------------------
   633 //
   835 //
   634 void CESMRMeetingTimeValidator::SetAlarmTimeFieldL(
   836 void CESMRMeetingTimeValidator::SetAlarmTimeFieldL(
   635         CEikTimeEditor& aAlarmTime )
   837         CEikTimeEditor& aAlarmTime )
   636     {
   838     {
   637     FUNC_LOG;
   839     FUNC_LOG;
       
   840     
   638     iAlarmTime = &aAlarmTime;
   841     iAlarmTime = &aAlarmTime;
       
   842     
       
   843     if ( iAlarmOnOff )
       
   844         {
       
   845         SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime );
       
   846         }
   639     }
   847     }
   640 
   848 
   641 // ---------------------------------------------------------------------------
   849 // ---------------------------------------------------------------------------
   642 // CESMRMeetingTimeValidator::SetAlarmDateFieldL
   850 // CESMRMeetingTimeValidator::SetAlarmDateFieldL
   643 // ---------------------------------------------------------------------------
   851 // ---------------------------------------------------------------------------
   645 void CESMRMeetingTimeValidator::SetAlarmDateFieldL(
   853 void CESMRMeetingTimeValidator::SetAlarmDateFieldL(
   646         CEikDateEditor& aAlarmDate )
   854         CEikDateEditor& aAlarmDate )
   647     {
   855     {
   648     FUNC_LOG;
   856     FUNC_LOG;
   649     iAlarmDate = &aAlarmDate;
   857     iAlarmDate = &aAlarmDate;
   650     }
   858     
   651 
   859     if ( iAlarmOnOff )
   652 // ---------------------------------------------------------------------------
   860         {
   653 // CESMRMeetingTimeValidator::StartTimeChangedL
   861         SetDateToEditor( *iAlarmDate, iCurrentAlarmTime );
       
   862         }
       
   863     }
       
   864 
       
   865 // ---------------------------------------------------------------------------
       
   866 // CESMRMeetingTimeValidator::SetRecurrenceUntilDateFieldL
   654 // ---------------------------------------------------------------------------
   867 // ---------------------------------------------------------------------------
   655 //
   868 //
   656 void CESMRMeetingTimeValidator::SetRecurrenceUntilDateFieldL(
   869 void CESMRMeetingTimeValidator::SetRecurrenceUntilDateFieldL(
   657         CEikDateEditor& aRecurrenceUntil )
   870         CEikDateEditor& aRecurrenceUntil )
   658     {
   871     {
   659     FUNC_LOG;
   872     FUNC_LOG;
   660     iRecurrenceUntilDate = &aRecurrenceUntil;
   873     iRecurrenceUntilDate = &aRecurrenceUntil;
       
   874     
       
   875     if ( Time::NullTTime() != iCurrentRecurrenceUntil )
       
   876         {
       
   877         SetDateToEditor( *iRecurrenceUntilDate, iCurrentRecurrenceUntil );       
       
   878         }
       
   879     
       
   880     }
       
   881 
       
   882 // ---------------------------------------------------------------------------
       
   883 // CESMRMeetingTimeValidator::SetAbsoluteAlarmOnOffFieldL
       
   884 // ---------------------------------------------------------------------------
       
   885 //
       
   886 void CESMRMeetingTimeValidator::SetAbsoluteAlarmOnOffFieldL( 
       
   887         MMRAbsoluteAlarmController& aAbsoluteAlarmController )
       
   888     {
       
   889     FUNC_LOG;
       
   890     iAbsoluteAlarmController = &aAbsoluteAlarmController;
   661     }
   891     }
   662 
   892 
   663 // ---------------------------------------------------------------------------
   893 // ---------------------------------------------------------------------------
   664 // CESMRMeetingTimeValidator::StartTimeChangedL
   894 // CESMRMeetingTimeValidator::StartTimeChangedL
   665 // ---------------------------------------------------------------------------
   895 // ---------------------------------------------------------------------------
   725         SetTimeToEditor( *iEndTime, iCurrentEndTime );
   955         SetTimeToEditor( *iEndTime, iCurrentEndTime );
   726         SetDateToEditor( *iEndDate, iCurrentEndTime );
   956         SetDateToEditor( *iEndDate, iCurrentEndTime );
   727         }
   957         }
   728 
   958 
   729     DrawEditorsDeferred();
   959     DrawEditorsDeferred();
   730 
       
   731     User::LeaveIfError( err );
   960     User::LeaveIfError( err );
   732     }
   961     }
   733 
   962 
   734 // ---------------------------------------------------------------------------
   963 // ---------------------------------------------------------------------------
   735 // CESMRMeetingTimeValidator::AlarmTimeChangedL
   964 // CESMRMeetingTimeValidator::AlarmTimeChangedL
   842 void CESMRMeetingTimeValidator::SetAlarmOnOffL(
  1071 void CESMRMeetingTimeValidator::SetAlarmOnOffL(
   843         TBool aAlarmOn )
  1072         TBool aAlarmOn )
   844     {
  1073     {
   845     FUNC_LOG;
  1074     FUNC_LOG;
   846     iAlarmOnOff = aAlarmOn;
  1075     iAlarmOnOff = aAlarmOn;
       
  1076     if( iAlarmOnOff )
       
  1077         {
       
  1078         iAbsoluteAlarmController->SetAbsoluteAlarmOn();
       
  1079         }
       
  1080     else
       
  1081         {
       
  1082         iAbsoluteAlarmController->SetAbsoluteAlarmOff();
       
  1083         }
   847 
  1084 
   848     if ( iAlarmOnOff && iAlldayEvent )
  1085     if ( iAlarmOnOff && iAlldayEvent )
   849         {
  1086         {
   850         TTime nullTime = Time::NullTTime();
       
   851 
       
   852         if ( iCurrentAlarmTime > iCurrentStartTime ||
  1087         if ( iCurrentAlarmTime > iCurrentStartTime ||
   853              iCurrentAlarmTime == nullTime )
  1088              iCurrentAlarmTime == Time::NullTTime() )
   854             {
  1089             {
   855             iCurrentAlarmTime = 
  1090             iCurrentAlarmTime = 
   856 				DefaultAlldayEventAlarmTime( iCurrentStartTime );
  1091 				DefaultAlldayEventAlarmTime( iCurrentStartTime );
   857             SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime );
  1092             SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime );
   858             SetDateToEditor( *iAlarmDate, iCurrentAlarmTime );
  1093             SetDateToEditor( *iAlarmDate, iCurrentAlarmTime );
   969         {
  1204         {
   970         iEndDate->PrepareForFocusLossL();
  1205         iEndDate->PrepareForFocusLossL();
   971         }
  1206         }
   972     if ( iAlarmOnOff && iAlarmTime && iAlldayEvent && iAlarmTime->IsVisible() )
  1207     if ( iAlarmOnOff && iAlarmTime && iAlldayEvent && iAlarmTime->IsVisible() )
   973         {
  1208         {
   974         TDateTime dt = iAlarmTime->Time().DateTime();
       
   975         iAlarmTime->PrepareForFocusLossL();
  1209         iAlarmTime->PrepareForFocusLossL();
   976         }
  1210         }
   977     if ( iAlarmOnOff && iAlarmDate && iAlldayEvent && iAlarmDate->IsVisible() )
  1211     if ( iAlarmOnOff && iAlarmDate && iAlldayEvent && iAlarmDate->IsVisible() )
   978         {
  1212         {
   979         iAlarmDate->PrepareForFocusLossL();
  1213         iAlarmDate->PrepareForFocusLossL();
   989 // ---------------------------------------------------------------------------
  1223 // ---------------------------------------------------------------------------
   990 //
  1224 //
   991 void CESMRMeetingTimeValidator::HandleStartTimeChangeL()
  1225 void CESMRMeetingTimeValidator::HandleStartTimeChangeL()
   992     {
  1226     {
   993     FUNC_LOG;
  1227     FUNC_LOG;
       
  1228     
       
  1229     TInt err( KErrNone );
       
  1230     
   994     TTime startTime = StartDateTime();
  1231     TTime startTime = StartDateTime();
   995     TTime endTime   = EndDateTime();
  1232     TTime endTime   = EndDateTime();
   996     
  1233     
   997     SetTimeToEditor( *iStartTime, startTime );
  1234     SetTimeToEditor( *iStartTime, startTime );
   998     SetDateToEditor( *iStartDate, startTime );
  1235     SetDateToEditor( *iStartDate, startTime );
  1001     User::LeaveIfError(
  1238     User::LeaveIfError(
  1002             startTime.MinutesFrom(
  1239             startTime.MinutesFrom(
  1003                     iCurrentStartTime,
  1240                     iCurrentStartTime,
  1004                     startTimeChange ) );
  1241                     startTimeChange ) );
  1005 
  1242 
  1006     endTime += startTimeChange;
  1243     if ( startTimeChange.Int() )
       
  1244         {
       
  1245         endTime += startTimeChange;
       
  1246         
       
  1247         if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry->Type() )
       
  1248             {
       
  1249             MESMRMeetingRequestEntry* mrEntry = 
       
  1250                     static_cast<MESMRMeetingRequestEntry*>( iEntry );
       
  1251             if ( mrEntry->IsRecurrentEventL() &&
       
  1252                  MESMRCalEntry::EESMRThisOnly == mrEntry->RecurrenceModRule() )
       
  1253                 {                
       
  1254                 TBool instanceAlreadyOnThisDay( 
       
  1255                            mrEntry->AnyInstancesBetweenTimePeriodL(startTime, endTime) );
       
  1256                 
       
  1257                 if ( instanceAlreadyOnThisDay )
       
  1258                     {
       
  1259                     // Restore previous time
       
  1260                     SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1261                     SetDateToEditor( *iStartDate, iCurrentStartTime );
       
  1262                     
       
  1263                     err = KErrOverflow;
       
  1264                     }
       
  1265                 else
       
  1266                     {
       
  1267                     TTime firstInstanceStart;
       
  1268                     TTime firstInstanceEnd;
       
  1269                     mrEntry->GetFirstInstanceStartAndEndTimeL( 
       
  1270                             firstInstanceStart,
       
  1271                             firstInstanceEnd );
       
  1272                     
       
  1273                     if ( startTime < firstInstanceStart )
       
  1274                         {
       
  1275                         SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1276                         SetDateToEditor( *iStartDate, iCurrentStartTime );
       
  1277                                             
       
  1278                         err = KErrUnderflow;
       
  1279                         }
       
  1280                     }
       
  1281                 }
       
  1282             }
       
  1283         
       
  1284         if ( MESMRCalEntry::EESMRCalEntryMeeting == iEntry->Type() )
       
  1285 			{
       
  1286 			if ( iEntry->IsRecurrentEventL() &&
       
  1287 				 MESMRCalEntry::EESMRThisOnly == iEntry->RecurrenceModRule() )
       
  1288 				{                
       
  1289 				TBool instanceAlreadyOnThisDay( 
       
  1290 						   iEntry->AnyInstancesBetweenTimePeriodL(
       
  1291 								   startTime, 
       
  1292 								   endTime ) );
       
  1293 				
       
  1294 				if ( instanceAlreadyOnThisDay )
       
  1295 					{
       
  1296 					// Restore previous time
       
  1297 					SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1298 					SetDateToEditor( *iStartDate, iCurrentStartTime );
       
  1299 					
       
  1300 					err = KErrOverflow;
       
  1301 					}
       
  1302 				else
       
  1303 					{
       
  1304 					TTime firstInstanceStart;
       
  1305 					TTime firstInstanceEnd;
       
  1306 					iEntry->GetFirstInstanceStartAndEndTimeL( 
       
  1307 							firstInstanceStart,
       
  1308 							firstInstanceEnd );
       
  1309 					
       
  1310 					if ( startTime < firstInstanceStart )
       
  1311 						{
       
  1312 						SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1313 						SetDateToEditor( *iStartDate, iCurrentStartTime );
       
  1314 											
       
  1315 						err = KErrUnderflow;
       
  1316 						}
       
  1317 					}
       
  1318 				}
       
  1319 			}
       
  1320         
       
  1321         if ( KErrNone == err )
       
  1322             {
       
  1323             SetTimeToEditor( *iEndTime, endTime );
       
  1324             SetDateToEditor( *iEndDate, endTime );
       
  1325         
       
  1326             iCurrentStartTime = startTime;
       
  1327             iCurrentEndTime = endTime;
       
  1328         
       
  1329             if ( iAlldayEvent && iAlarmOnOff &&
       
  1330                  iAlarmTime->IsVisible() && iAlarmDate->IsVisible() )
       
  1331                 {
       
  1332                 TTime alarmTime = AlarmDateTime();
       
  1333                 alarmTime += startTimeChange;
       
  1334         
       
  1335                 SetTimeToEditor( *iAlarmTime, alarmTime );
       
  1336                 SetDateToEditor( *iAlarmDate, alarmTime );
       
  1337         
       
  1338                 iCurrentAlarmTime = alarmTime;
       
  1339                 }
       
  1340         
       
  1341             if ( ERecurrenceNot != iRecurrenceValue &&
       
  1342                     iRecurrenceUntilDate && iRecurrenceUntilDate->IsVisible() )
       
  1343                 {
       
  1344                 TTime recUntil = RecurrenceUntilTime();
       
  1345         
       
  1346                 if ( startTime.DateTime().Day() != iComparativeStartTime.Day() ||
       
  1347                      startTime.DateTime().Month() != iComparativeStartTime.Month() ||
       
  1348                      startTime.DateTime().Year() != iComparativeStartTime.Year() )
       
  1349                     {
       
  1350                     // We want to update the recurrence until only when
       
  1351                     // a) Day, b) Month, c) or Year of the start time has changed
       
  1352                     recUntil += startTimeChange;
       
  1353                     iComparativeStartTime = startTime.DateTime();
       
  1354                     }
       
  1355         
       
  1356                 SetDateToEditor( *iRecurrenceUntilDate, recUntil );
       
  1357                 iCurrentRecurrenceUntil = recUntil;
       
  1358                 }        
       
  1359             }
       
  1360         }
  1007     
  1361     
  1008     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry->Type() )
  1362     DrawEditorsDeferred();
  1009         {
  1363     User::LeaveIfError( err );
  1010         MESMRMeetingRequestEntry* mrEntry = 
       
  1011                 static_cast<MESMRMeetingRequestEntry*>( iEntry );
       
  1012         if ( mrEntry->IsRecurrentEventL() &&
       
  1013              MESMRCalEntry::EESMRThisOnly == mrEntry->RecurrenceModRule() )
       
  1014             {
       
  1015             TBool instanceAlreadyOnThisDay( 
       
  1016                        mrEntry->AnyInstanceOnDayL(startTime, endTime) );
       
  1017             
       
  1018             if ( instanceAlreadyOnThisDay )
       
  1019                 {
       
  1020                 // Restore previous time
       
  1021                 SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1022                 SetDateToEditor( *iStartDate, iCurrentStartTime );
       
  1023                 
       
  1024                 User::Leave( KErrOverflow );
       
  1025                 }
       
  1026             }
       
  1027         }
       
  1028     
       
  1029     SetTimeToEditor( *iEndTime, endTime );
       
  1030     SetDateToEditor( *iEndDate, endTime );
       
  1031 
       
  1032     iCurrentStartTime = startTime;
       
  1033     iCurrentEndTime = endTime;
       
  1034 
       
  1035     if ( iAlldayEvent && iAlarmOnOff &&
       
  1036          iAlarmTime->IsVisible() && iAlarmDate->IsVisible() )
       
  1037         {
       
  1038         TTime alarmTime = AlarmDateTime();
       
  1039         alarmTime += startTimeChange;
       
  1040 
       
  1041         SetTimeToEditor( *iAlarmTime, alarmTime );
       
  1042         SetDateToEditor( *iAlarmDate, alarmTime );
       
  1043 
       
  1044         iCurrentAlarmTime = alarmTime;
       
  1045         }
       
  1046 
       
  1047     if ( ERecurrenceNot != iRecurrenceValue &&
       
  1048             iRecurrenceUntilDate && iRecurrenceUntilDate->IsVisible() )
       
  1049         {
       
  1050         TTime recUntil = RecurrenceUntilTime();
       
  1051 
       
  1052         if ( startTime.DateTime().Day() != iComparativeStartTime.Day() ||
       
  1053              startTime.DateTime().Month() != iComparativeStartTime.Month() ||
       
  1054              startTime.DateTime().Year() != iComparativeStartTime.Year() )
       
  1055             {
       
  1056             // We want to update the recurrence until only when
       
  1057             // a) Day, b) Month, c) or Year of the start time has changed
       
  1058             recUntil += startTimeChange;
       
  1059             iComparativeStartTime = startTime.DateTime();
       
  1060             }
       
  1061 
       
  1062         SetDateToEditor( *iRecurrenceUntilDate, recUntil );
       
  1063         iCurrentRecurrenceUntil = recUntil;
       
  1064         }
       
  1065     }
  1364     }
  1066 
  1365 
  1067 // ---------------------------------------------------------------------------
  1366 // ---------------------------------------------------------------------------
  1068 // CESMRMeetingTimeValidator::HandleEndTimeChangeL
  1367 // CESMRMeetingTimeValidator::HandleEndTimeChangeL
  1069 // ---------------------------------------------------------------------------
  1368 // ---------------------------------------------------------------------------
  1071 void CESMRMeetingTimeValidator::HandleEndTimeChangeL()
  1370 void CESMRMeetingTimeValidator::HandleEndTimeChangeL()
  1072     {
  1371     {
  1073     FUNC_LOG;
  1372     FUNC_LOG;
  1074     TInt err( KErrNone );
  1373     TInt err( KErrNone );
  1075     TTime startTime = StartDateTime();
  1374     TTime startTime = StartDateTime();
  1076     TTime endTime   = EndDateTime();
  1375     TTime endTime = EndDateTime();
  1077 
  1376 
  1078     if ( !iAlldayEvent && endTime < startTime )
  1377     // Check first if end time has even changed
  1079         {
  1378     TTimeIntervalMinutes endTimeChange;
  1080         if( ERecurrenceNot != iRecurrenceValue )
  1379     User::LeaveIfError(
  1081             {
  1380             endTime.MinutesFrom(
  1082             err = KErrArgument;
  1381                     iCurrentEndTime,
  1083             }
  1382                     endTimeChange ) );    
  1084         else
  1383     
  1085             {
  1384     if ( endTimeChange.Int() )
  1086             // End time is earlier than start time
  1385         {    
  1087             // and this is not allday event.
  1386         if ( !iAlldayEvent && endTime < startTime )
  1088             endTime += TTimeIntervalDays( KOne );
  1387             {
  1089             }
  1388             if( ERecurrenceNot != iRecurrenceValue )
  1090         }
  1389                 {
  1091 
  1390                 err = KErrArgument;
  1092     if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry->Type() )
  1391                 }
  1093         {
  1392             else
  1094         // Check that is modified entry 
  1393                 {
  1095         MESMRMeetingRequestEntry* mrEntry = 
  1394                 // End time is earlier than start time
  1096                 static_cast<MESMRMeetingRequestEntry*>( iEntry );
  1395                 // and this is not allday event.
  1097         if ( mrEntry->IsRecurrentEventL() &&
  1396                 endTime += TTimeIntervalDays( KOne );
  1098              MESMRCalEntry::EESMRThisOnly == mrEntry->RecurrenceModRule() )
  1397                 }
  1099             {
  1398             }
  1100             TBool instanceAlreadyOnThisDay( 
  1399     
  1101                        mrEntry->AnyInstanceOnDayL(startTime, endTime) );
  1400         if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == iEntry->Type() )
  1102             
  1401             {
  1103             if ( instanceAlreadyOnThisDay )
  1402             // Check that is modified entry 
  1104                 {
  1403             MESMRMeetingRequestEntry* mrEntry = 
  1105                 // Restore previous time
  1404                     static_cast<MESMRMeetingRequestEntry*>( iEntry );
  1106                 SetTimeToEditor( *iStartTime, iCurrentStartTime );
  1405             if ( mrEntry->IsRecurrentEventL() &&
  1107                 SetDateToEditor( *iStartDate, iCurrentStartTime );
  1406                  MESMRCalEntry::EESMRThisOnly == mrEntry->RecurrenceModRule() )
       
  1407                 {
       
  1408                 TBool instanceAlreadyOnThisDay( 
       
  1409                            mrEntry->AnyInstancesBetweenTimePeriodL(startTime, endTime) );
  1108                 
  1410                 
  1109                 err = KErrOverflow;
  1411                 if ( instanceAlreadyOnThisDay )
  1110                 }
  1412                     {
  1111             }
  1413                     // Restore previous time
  1112         }    
  1414                     SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1415                     SetDateToEditor( *iStartDate, iCurrentStartTime );
       
  1416                     
       
  1417                     err = KErrOverflow;
       
  1418                     }
       
  1419                 else
       
  1420                     {
       
  1421                     TTime firstInstanceStart;
       
  1422                     TTime firstInstanceEnd;
       
  1423                     mrEntry->GetFirstInstanceStartAndEndTimeL( 
       
  1424                             firstInstanceStart,
       
  1425                             firstInstanceEnd );
       
  1426                     
       
  1427                     if ( startTime < firstInstanceStart )
       
  1428                         {
       
  1429                         // Restore previous time
       
  1430                         SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1431                         SetTimeToEditor( *iEndTime, iCurrentEndTime );
       
  1432                         
       
  1433                         err = KErrUnderflow;
       
  1434                         }
       
  1435                     }                
       
  1436                 }
       
  1437             }
       
  1438         
       
  1439         if ( MESMRCalEntry::EESMRCalEntryMeeting == iEntry->Type() )
       
  1440 			{
       
  1441 			// Check that is modified entry 
       
  1442 			if ( iEntry->IsRecurrentEventL() &&
       
  1443 				 MESMRCalEntry::EESMRThisOnly == iEntry->RecurrenceModRule() )
       
  1444 				{
       
  1445 				TBool instanceAlreadyOnThisDay( 
       
  1446 						   iEntry->AnyInstancesBetweenTimePeriodL( 
       
  1447 								   startTime, 
       
  1448 								   endTime ) );
       
  1449 				
       
  1450 				if ( instanceAlreadyOnThisDay )
       
  1451 					{
       
  1452 					// Restore previous time
       
  1453 					SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1454 					SetDateToEditor( *iStartDate, iCurrentStartTime );
       
  1455 					
       
  1456 					err = KErrOverflow;
       
  1457 					}
       
  1458 				else
       
  1459 					{
       
  1460 					TTime firstInstanceStart;
       
  1461 					TTime firstInstanceEnd;
       
  1462 					iEntry->GetFirstInstanceStartAndEndTimeL( 
       
  1463 							firstInstanceStart,
       
  1464 							firstInstanceEnd );
       
  1465 					
       
  1466 					if ( startTime < firstInstanceStart )
       
  1467 						{
       
  1468 						// Restore previous time
       
  1469 						SetTimeToEditor( *iStartTime, iCurrentStartTime );
       
  1470 						SetTimeToEditor( *iEndTime, iCurrentEndTime );
       
  1471 						
       
  1472 						err = KErrUnderflow;
       
  1473 						}
       
  1474 					}                
       
  1475 				}
       
  1476 			}    
       
  1477         
       
  1478         if ( KErrNone == err )
       
  1479             {
       
  1480             iCurrentStartTime = startTime;
       
  1481             iCurrentEndTime = endTime;
       
  1482             }
  1113     
  1483     
  1114     if ( KErrNone == err )
  1484         if ( !iAlldayEvent )
  1115         {
  1485             {
  1116         iCurrentStartTime = startTime;
  1486             SetTimeToEditor( *iStartTime, iCurrentStartTime );
  1117         iCurrentEndTime = endTime;
  1487             SetTimeToEditor( *iEndTime, iCurrentEndTime );
  1118         }
  1488             }
  1119 
  1489     
  1120     if ( !iAlldayEvent )
  1490         SetDateToEditor( *iStartDate, iCurrentStartTime );
  1121         {
  1491         SetDateToEditor( *iEndDate, iCurrentEndTime );
  1122         SetTimeToEditor( *iStartTime, iCurrentStartTime );
  1492     
  1123         SetTimeToEditor( *iEndTime, iCurrentEndTime );
  1493         DrawEditorsDeferred();
  1124         }
  1494         User::LeaveIfError( err );
  1125 
  1495         }
  1126     SetDateToEditor( *iStartDate, iCurrentStartTime );
       
  1127     SetDateToEditor( *iEndDate, iCurrentEndTime );
       
  1128 
       
  1129     User::LeaveIfError( err );
       
  1130     }
  1496     }
  1131 
  1497 
  1132 // ---------------------------------------------------------------------------
  1498 // ---------------------------------------------------------------------------
  1133 // CESMRMeetingTimeValidator::HandleAlarmTimeChangedL
  1499 // CESMRMeetingTimeValidator::HandleAlarmTimeChangedL
  1134 // ---------------------------------------------------------------------------
  1500 // ---------------------------------------------------------------------------
  1213         {
  1579         {
  1214         TTime start = StartDateTime();
  1580         TTime start = StartDateTime();
  1215         TTime minTimeForRecurrenceEnd =
  1581         TTime minTimeForRecurrenceEnd =
  1216                 TimeForNextInstaceStartTime( iRecurrenceValue, start );
  1582                 TimeForNextInstaceStartTime( iRecurrenceValue, start );
  1217 
  1583 
  1218         TDateTime a = iCurrentRecurrenceUntil.DateTime();
  1584         if ( Time::NullTTime() == iCurrentRecurrenceUntil || 
  1219         TDateTime b = minTimeForRecurrenceEnd.DateTime();
  1585              iCurrentRecurrenceUntil < minTimeForRecurrenceEnd )
  1220 
       
  1221         if ( iCurrentRecurrenceUntil < minTimeForRecurrenceEnd )
       
  1222             {
  1586             {
  1223             iCurrentRecurrenceUntil = minTimeForRecurrenceEnd;
  1587             iCurrentRecurrenceUntil = minTimeForRecurrenceEnd;
  1224             }
  1588             }
  1225         }
  1589         }
  1226     else
  1590     else
  1227         {
  1591         {
  1228         iCurrentRecurrenceUntil = StartDateTime();
  1592         iCurrentRecurrenceUntil = StartDateTime();
  1229         }
  1593         }
  1230 
  1594     
  1231     if ( iRecurrenceUntilDate )
  1595     if ( iRecurrenceUntilDate )
  1232         {
  1596         {
  1233         SetDateToEditor( *iRecurrenceUntilDate, iCurrentRecurrenceUntil );
  1597         SetDateToEditor( *iRecurrenceUntilDate, iCurrentRecurrenceUntil );
  1234         }
  1598         }
  1235     }
  1599     }
  1255         iCurrentRecurrenceUntil = recurrenceUntilTime;
  1619         iCurrentRecurrenceUntil = recurrenceUntilTime;
  1256         }
  1620         }
  1257 
  1621 
  1258     if ( iRecurrenceUntilDate )
  1622     if ( iRecurrenceUntilDate )
  1259         {
  1623         {
  1260         SetDateToEditor( *iRecurrenceUntilDate, iCurrentRecurrenceUntil );
  1624         SetDateToEditor( 
       
  1625                 *iRecurrenceUntilDate, 
       
  1626                 iCurrentRecurrenceUntil );
  1261         }
  1627         }
  1262 
  1628 
  1263     User::LeaveIfError( err );
  1629     User::LeaveIfError( err );
  1264     }
  1630     }
  1265 
  1631 
  1407         }
  1773         }
  1408     else
  1774     else
  1409         {
  1775         {
  1410         iCurrentAlarmTime = Time::NullTTime();
  1776         iCurrentAlarmTime = Time::NullTTime();
  1411         iAlarmOnOff = EFalse;
  1777         iAlarmOnOff = EFalse;
       
  1778         iAbsoluteAlarmController->SetAbsoluteAlarmOff();
  1412         }
  1779         }
  1413 
  1780 
  1414     CleanupStack::PopAndDestroy( alarm );
  1781     CleanupStack::PopAndDestroy( alarm );
  1415     alarm = NULL;
  1782     alarm = NULL;
  1416 
  1783 
  1441             // Recurrence time has to be shown in the editor as local time
  1808             // Recurrence time has to be shown in the editor as local time
  1442             TCalTime recurrenceTime;
  1809             TCalTime recurrenceTime;
  1443             recurrenceTime.SetTimeUtcL( iCurrentRecurrenceUntil );
  1810             recurrenceTime.SetTimeUtcL( iCurrentRecurrenceUntil );
  1444             TTime localRecurrenceTime = recurrenceTime.TimeLocalL();
  1811             TTime localRecurrenceTime = recurrenceTime.TimeLocalL();
  1445             
  1812             
  1446             SetDateToEditor( *iRecurrenceUntilDate, localRecurrenceTime );
  1813             SetDateToEditor( 
       
  1814                     *iRecurrenceUntilDate, 
       
  1815                     localRecurrenceTime );
  1447             }
  1816             }
  1448         }
  1817         }
  1449     else
  1818     else
  1450         {
  1819         {
  1451         iRecurrenceValue = ERecurrenceNot;        
  1820         iRecurrenceValue = ERecurrenceNot;        
  1512         TTime recurUntil = RecurrenceUntilTime();
  1881         TTime recurUntil = RecurrenceUntilTime();
  1513         if ( ERecurrenceUnknown != iRecurrenceValue &&
  1882         if ( ERecurrenceUnknown != iRecurrenceValue &&
  1514              recurUntil < startTime )
  1883              recurUntil < startTime )
  1515             {
  1884             {
  1516             recurUntil = startTime + TTimeIntervalYears( KOne );
  1885             recurUntil = startTime + TTimeIntervalYears( KOne );
  1517             iCurrentRecurrenceUntil = recurUntil;
  1886             }
  1518             }
  1887         iCurrentRecurrenceUntil = recurUntil;
  1519         }
  1888         }
  1520 
  1889 
  1521     if ( iAlldayEvent && iAlarmOnOff )
  1890     if ( iAlldayEvent && iAlarmOnOff )
  1522         {
  1891         {
  1523         // For alarm following cehcks and corrections are made:
  1892         // For alarm following cehcks and corrections are made:
  1547             {
  1916             {
  1548             if ( !iEntry->IsStoredL() )
  1917             if ( !iEntry->IsStoredL() )
  1549                 {
  1918                 {
  1550                 // Setting alarm to default value if entry is not stored
  1919                 // Setting alarm to default value if entry is not stored
  1551                 iAlarmOnOff = EFalse;
  1920                 iAlarmOnOff = EFalse;
       
  1921                 iAbsoluteAlarmController->SetAbsoluteAlarmOff();
  1552                 }
  1922                 }
  1553             }
  1923             }
  1554 
  1924 
  1555         iCurrentAlarmTime = alarmTime;
  1925         iCurrentAlarmTime = alarmTime;
  1556         }
  1926         }
  1577     // End
  1947     // End
  1578     SetTimeToEditor( *iEndTime, endTime );
  1948     SetTimeToEditor( *iEndTime, endTime );
  1579     SetDateToEditor( *iEndDate, endTime );
  1949     SetDateToEditor( *iEndDate, endTime );
  1580 
  1950 
  1581     // Alarm
  1951     // Alarm
  1582     if(iAlarmTime)
  1952     if( iAlarmOnOff && iAlarmTime )
  1583         {
  1953         {
  1584         SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime );
  1954         SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime );
  1585         }
  1955         }
  1586 
  1956 
  1587     if(iAlarmDate)
  1957     if( iAlarmOnOff && iAlarmDate )
  1588         {
  1958         {
  1589         SetDateToEditor( *iAlarmDate, iCurrentAlarmTime );
  1959         SetDateToEditor( *iAlarmDate, iCurrentAlarmTime );
  1590         }
  1960         }
  1591 
       
  1592 
  1961 
  1593     // if editing certain occurance of recurrent event series
  1962     // if editing certain occurance of recurrent event series
  1594     // the repeat until date is not available.
  1963     // the repeat until date is not available.
  1595     if ( iRecurrenceUntilDate )
  1964     if ( iRecurrenceUntilDate )
  1596         {
  1965         {
  1597         // Recurrence until
  1966         // Recurrence until
  1598         SetDateToEditor( *iRecurrenceUntilDate, iCurrentRecurrenceUntil );
  1967         SetDateToEditor( *iRecurrenceUntilDate, iCurrentRecurrenceUntil );
  1599         }
  1968         }
  1600 
  1969     }
  1601     }
       
  1602 
       
  1603 
  1970 
  1604 // ---------------------------------------------------------------------------
  1971 // ---------------------------------------------------------------------------
  1605 // CESMRMeetingTimeValidator::ForceEndDateTime
  1972 // CESMRMeetingTimeValidator::ForceEndDateTime
  1606 // ---------------------------------------------------------------------------
  1973 // ---------------------------------------------------------------------------
  1607 //
  1974 //
  1672 void CESMRMeetingTimeValidator::WriteStartAndEndTimeToEntryL(
  2039 void CESMRMeetingTimeValidator::WriteStartAndEndTimeToEntryL(
  1673         MESMRCalEntry& aEntry )
  2040         MESMRCalEntry& aEntry )
  1674     {
  2041     {
  1675     FUNC_LOG;
  2042     FUNC_LOG;
  1676     CCalEntry& entry( aEntry.Entry() );
  2043     CCalEntry& entry( aEntry.Entry() );
  1677     const CCalEntry& originalEntry( aEntry.OriginalEntry() );
       
  1678 
  2044 
  1679     TTime startTime = StartDateTime();
  2045     TTime startTime = StartDateTime();
  1680     TTime endTime = EndDateTime();
  2046     TTime endTime = EndDateTime();
  1681 
  2047 
  1682     TTime orgStartTime = originalEntry.StartTimeL().TimeLocalL();
  2048     TTime orgStartTime = entry.StartTimeL().TimeLocalL();
  1683     TTime orgEndTime   = originalEntry.EndTimeL().TimeLocalL();
  2049     TTime orgEndTime   = entry.EndTimeL().TimeLocalL();
  1684 
  2050 
  1685     if ( !aEntry.IsStoredL() || orgStartTime != startTime ||
  2051     if ( !aEntry.IsStoredL() || orgStartTime != startTime ||
  1686          orgEndTime != endTime )
  2052          orgEndTime != endTime )
  1687         {
  2053         {
  1688         // End time has changed --> Store it to entry
  2054         // End time has changed --> Store it to entry