10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description : ESMR conflict checker implementation |
14 * Description : ESMR conflict checker implementation |
15 * Version : %version: e002sa33#9 % |
15 * Version : %version: e002sa33#10.1.2 % |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 #include "emailtrace.h" |
19 #include "emailtrace.h" |
20 #include "cesmrconflictchecker.h" |
20 #include "cesmrconflictchecker.h" |
21 #include "cesmrcaldbmgr.h" |
21 #include "cesmrcaldbmgr.h" |
22 #include "esmrhelper.h" |
22 #include "esmrhelper.h" |
23 #include "esmrentryhelper.h" |
23 #include "esmrentryhelper.h" |
24 #include "esmrinternaluid.h" |
24 #include "esmrinternaluid.h" |
|
25 #include "cesmrcaluserutil.h" |
25 |
26 |
26 #include <calcommon.h> |
27 #include <calcommon.h> |
27 #include <calinstance.h> |
28 #include <calinstance.h> |
28 #include <calentryview.h> |
29 #include <calentryview.h> |
29 #include <calinstanceview.h> |
30 #include <calinstanceview.h> |
543 CleanupStack::PopAndDestroy( &days ); |
545 CleanupStack::PopAndDestroy( &days ); |
544 CleanupStack::PopAndDestroy( &tmpInstanceArray ); |
546 CleanupStack::PopAndDestroy( &tmpInstanceArray ); |
545 } |
547 } |
546 |
548 |
547 /** |
549 /** |
|
550 * Judge is one CCalEntry is a all day event |
|
551 * @param aEntry the entry be checked |
|
552 * @return ETure if it is a all day event |
|
553 */ |
|
554 TBool IsAllDayEventL( const CCalEntry& aEntry ) |
|
555 { |
|
556 FUNC_LOG; |
|
557 // for judge all day event |
|
558 CCalEntry* tmpEntry = ESMRHelper::CopyEntryLC( |
|
559 aEntry, |
|
560 aEntry.MethodL(), |
|
561 ESMRHelper::ECopyFull ); |
|
562 |
|
563 CESMRCalUserUtil* entryUtil = CESMRCalUserUtil::NewLC( *tmpEntry ); |
|
564 TBool allDayEvent( entryUtil->IsAlldayEventL() ); |
|
565 CleanupStack::PopAndDestroy( entryUtil ); |
|
566 CleanupStack::PopAndDestroy( tmpEntry ); |
|
567 |
|
568 return allDayEvent; |
|
569 } |
|
570 /** |
|
571 * Get the first visible instance from the iterater. |
|
572 * @param aIterater the handler of the iterater. |
|
573 * @return the first instance |
|
574 */ |
|
575 CCalInstance* FirstInstanceL ( CCalInstanceIterator* aIterater) |
|
576 { |
|
577 FUNC_LOG; |
|
578 CCalInstance* previous = aIterater->PreviousL(); |
|
579 while( previous ) |
|
580 { |
|
581 CleanupStack::PushL( previous ); |
|
582 CleanupStack::PopAndDestroy( previous ); |
|
583 previous = aIterater->PreviousL(); |
|
584 } |
|
585 |
|
586 CCalInstance* next = aIterater->NextL(); |
|
587 CleanupStack::PushL( next ); |
|
588 CleanupStack::PopAndDestroy( next ); |
|
589 previous = aIterater->PreviousL(); |
|
590 return previous; |
|
591 } |
|
592 |
|
593 /** |
548 * Finds conflict for recurrent entry |
594 * Finds conflict for recurrent entry |
549 */ |
595 */ |
550 void FindConflictsForRepeatingMeetingL( |
596 void FindConflictsForRepeatingMeetingL( |
551 const CCalEntry& aEntry, |
597 const CCalEntry& aEntry, |
552 RPointerArray< CCalInstance >& aInstances, |
598 RPointerArray< CCalInstance >& aInstances, |
560 if ( instance ) // Instance is stored |
606 if ( instance ) // Instance is stored |
561 { |
607 { |
562 CleanupStack::PushL( instance ); |
608 CleanupStack::PushL( instance ); |
563 RCPointerArray< CCalInstance > tmpInstanceArray; |
609 RCPointerArray< CCalInstance > tmpInstanceArray; |
564 CleanupClosePushL( tmpInstanceArray ); |
610 CleanupClosePushL( tmpInstanceArray ); |
565 |
|
566 CCalEntry& parent = instance->Entry(); |
611 CCalEntry& parent = instance->Entry(); |
567 CCalInstanceView* instanceView = aDb.InstanceViewL( parent ); |
612 CCalInstanceView* instanceView = aDb.InstanceViewL( aEntry ); |
|
613 |
|
614 // create the iterator for instances by current entry |
568 CCalInstanceIterator* iterator = instanceView->FindInstanceByUidL( |
615 CCalInstanceIterator* iterator = instanceView->FindInstanceByUidL( |
569 parent.UidL(), |
616 aEntry.UidL(), |
570 parent.StartTimeL() ); |
617 aEntry.StartTimeL() ); |
|
618 |
571 CleanupStack::PushL( iterator ); |
619 CleanupStack::PushL( iterator ); |
572 CCalEntry* entry = ESMRHelper::CopyEntryLC( |
620 CCalEntry* entry = ESMRHelper::CopyEntryLC( |
573 parent, |
621 parent, |
574 parent.MethodL(), |
622 parent.MethodL(), |
575 ESMRHelper::ECopyFull ); |
623 ESMRHelper::ECopyFull ); |
576 |
624 // For CCalInstanceIterator class don't have any function on how to get current instance, |
577 while ( iterator->HasMore() ) |
625 // handle the special situation for it. |
578 { |
626 if( iterator ->Count() == 1 ) |
579 CCalInstance* next = iterator->NextL(); |
627 { |
580 CleanupStack::PushL( next ); |
628 entry->SetStartAndEndTimeL( aEntry.StartTimeL(), aEntry.EndTimeL() ); |
581 entry->SetStartAndEndTimeL( next->StartTimeL(), next->EndTimeL() ); |
629 |
582 CleanupStack::PopAndDestroy( next ); |
630 FindConflictsForEntryL( *entry, |
583 FindConflictsForEntryL( *entry, |
631 tmpInstanceArray, |
584 tmpInstanceArray, |
632 aDb ); |
585 aDb ); |
633 |
586 |
634 if ( tmpInstanceArray.Count() ) |
587 if ( tmpInstanceArray.Count() ) |
635 { |
588 { |
636 MoveInstancesL( tmpInstanceArray, aInstances ); |
589 MoveInstancesL( tmpInstanceArray, aInstances ); |
637 } |
590 |
638 } |
591 if ( !aFindAllConflicts ) |
639 else |
592 { |
640 { |
593 break; |
641 // For CCalInstanceIterator class don't have any function on how to get current instance, |
594 } |
642 // handle the first instance action when find conflict. |
595 } |
643 CCalInstance* previous = FirstInstanceL( iterator ); |
596 } |
644 CleanupStack::PushL( previous ); |
|
645 entry->SetStartAndEndTimeL( previous->StartTimeL(), previous->EndTimeL() ); |
|
646 CleanupStack::PopAndDestroy( previous ); |
|
647 FindConflictsForEntryL( *entry, tmpInstanceArray, aDb ); |
|
648 |
|
649 if ( tmpInstanceArray.Count() ) |
|
650 { |
|
651 MoveInstancesL( tmpInstanceArray, aInstances ); |
|
652 } |
|
653 // does the normal find conflict action. From the second to the end. |
|
654 while ( iterator->HasMore() ) |
|
655 { |
|
656 CCalInstance* next = iterator->NextL(); |
|
657 CleanupStack::PushL( next ); |
|
658 entry->SetStartAndEndTimeL( next->StartTimeL(), next->EndTimeL() ); |
|
659 |
|
660 CleanupStack::PopAndDestroy( next ); |
|
661 |
|
662 FindConflictsForEntryL( *entry, |
|
663 tmpInstanceArray, |
|
664 aDb ); |
|
665 |
|
666 if ( tmpInstanceArray.Count() ) |
|
667 { |
|
668 MoveInstancesL( tmpInstanceArray, aInstances ); |
|
669 } |
|
670 } |
|
671 } |
597 |
672 |
598 CleanupStack::PopAndDestroy( entry ); |
673 CleanupStack::PopAndDestroy( entry ); |
599 |
674 |
600 CleanupStack::PopAndDestroy( iterator ); |
675 CleanupStack::PopAndDestroy( iterator ); |
601 |
676 |