22 #include "esmrdef.h" |
22 #include "esmrdef.h" |
23 #include "cesmrpolicymanager.h" |
23 #include "cesmrpolicymanager.h" |
24 //</cmail> |
24 //</cmail> |
25 |
25 |
26 #include "cesmrviewerctrl.h" |
26 #include "cesmrviewerctrl.h" |
27 #include "cesmrentryprocessor.h" |
27 #include "cmrentryprocessor.h" |
28 #include "mesmrmeetingrequestentry.h" |
28 #include "mesmrmeetingrequestentry.h" |
29 #include "mesmrtaskextension.h" |
29 #include "mesmrtaskextension.h" |
30 //<cmail> |
30 #include "esmrentryhelper.h" |
|
31 #include "esmrhelper.h" |
31 #include "cesmruifactory.h" |
32 #include "cesmruifactory.h" |
32 //</cmail> |
33 |
33 #include "mesmruibase.h" |
34 #include "mesmruibase.h" |
34 #include "tesmrinputparams.h" |
35 #include "tesmrinputparams.h" |
|
36 #include "tmroutputparams.h" |
35 #include "esmrconfig.hrh" |
37 #include "esmrconfig.hrh" |
36 #include "cesmrconfirmationquery.h" |
38 #include "cesmrconfirmationquery.h" |
37 #include "cesmrutils.h" |
39 #include "cesmrutils.h" |
38 #include "cesmrattachmentinfo.h" |
|
39 #include "cesmrcaluserutil.h" |
40 #include "cesmrcaluserutil.h" |
40 // <cmail> Removed profiling. </cmail> |
41 #include "cesmrlistquery.h" |
|
42 #include "cesmrcaldbmgr.h" |
|
43 |
|
44 #include "cesmrtaskfactory.h" |
|
45 #include "cesmrtaskextensionimpl.h" |
41 |
46 |
42 // Logging utilities |
47 // Logging utilities |
43 |
48 |
44 // From System |
49 // From System |
45 //<cmail> |
50 //<cmail> |
46 #include <CMRUtils.h> |
51 #include <cmrutils.h> |
47 #include "esmrutilsapiext.h" |
52 #include "esmrutilsapiext.h" |
48 //</cmail> |
53 //</cmail> |
49 #include <msvstd.h> |
54 #include <msvstd.h> |
50 #include <msvids.h> |
55 #include <msvids.h> |
51 //<cmail> |
56 //<cmail> |
52 #include "FreestyleEmailUiConstants.h" |
57 #include "FreestyleEmailUiConstants.h" |
53 //</cmail> |
58 //</cmail> |
54 #include <eikappui.h> |
59 #include <eikappui.h> |
55 #include <eikenv.h> |
60 #include <eikenv.h> |
|
61 #include <calentry.h> |
|
62 #include <caleninterimutils2.h> |
|
63 #include <calcommon.h> |
56 |
64 |
57 // CONSTANTS |
65 // CONSTANTS |
58 /// Unnamed namespace for local definitions |
66 /// Unnamed namespace for local definitions |
59 namespace { // codescanner::namespace |
67 namespace { // codescanner::namespace |
60 |
68 |
68 { |
76 { |
69 EESMRViewerCtrlSyncher = 0, // Syncher is not created, |
77 EESMRViewerCtrlSyncher = 0, // Syncher is not created, |
70 EESMRViewerCtrlProcessor, |
78 EESMRViewerCtrlProcessor, |
71 EESMRViewerCtrlTaskExt, |
79 EESMRViewerCtrlTaskExt, |
72 EESMRViewerCtrlPolicyMgr, |
80 EESMRViewerCtrlPolicyMgr, |
|
81 EESMRViewerCtrlInvalidModifyingRule, |
|
82 EESMRViewerCtrlInvalidEntryType |
73 }; |
83 }; |
74 |
84 |
75 void Panic(TMRViewerCtrlPanicCode aPanicCode) |
85 void Panic(TMRViewerCtrlPanicCode aPanicCode) |
76 { |
86 { |
77 User::Panic( KMRViewerCtrlPanicTxt, aPanicCode ); |
87 User::Panic( KMRViewerCtrlPanicTxt, aPanicCode ); |
78 } |
88 } |
79 |
89 |
80 #endif |
90 #endif |
81 |
91 |
82 /** |
92 /** |
83 * Tests if entry contains attachments or not. |
93 * Maps calendar entry type to MR entry type |
84 * @param aEntry Reference to meeting request entry. |
94 * @param aEntryType to be mapped to MR entry type |
85 * @return ETrue if entry contains attachments |
95 * @return MR event type |
86 */ |
96 */ |
87 TBool ContainsAttachmentsL( |
97 TESMRCalendarEventType MapType( const CCalEntry& aEntry ) |
88 MESMRMeetingRequestEntry& aEntry ) |
98 { |
89 { |
99 TESMRCalendarEventType type( EESMREventTypeNone ); |
90 TBool retValue( EFalse ); |
100 |
91 |
101 switch ( aEntry.EntryTypeL() ) |
92 TESMRInputParams esmrInputParams; |
102 { |
93 if ( aEntry.StartupParameters(esmrInputParams) ) |
103 case CCalEntry::EAppt: |
94 { |
104 { |
95 if ( esmrInputParams.iAttachmentInfo && |
105 if( CCalenInterimUtils2::IsMeetingRequestL( |
96 esmrInputParams.iAttachmentInfo->AttachmentCount() ) |
106 ( const_cast<CCalEntry&>( aEntry ) ) ) ) |
97 { |
107 { |
98 retValue = ETrue; |
108 type = EESMREventTypeMeetingRequest; |
99 } |
109 } |
100 } |
110 else |
101 return retValue; |
111 { |
|
112 type = EESMREventTypeAppt; |
|
113 } |
|
114 break; |
|
115 } |
|
116 case CCalEntry::ETodo: |
|
117 { |
|
118 type = EESMREventTypeETodo; |
|
119 break; |
|
120 } |
|
121 case CCalEntry::EEvent: |
|
122 { |
|
123 type = EESMREventTypeEEvent; |
|
124 break; |
|
125 } |
|
126 case CCalEntry::EReminder: |
|
127 { |
|
128 type = EESMREventTypeEReminder; |
|
129 break; |
|
130 } |
|
131 case CCalEntry::EAnniv: |
|
132 { |
|
133 type = EESMREventTypeEAnniv; |
|
134 break; |
|
135 } |
|
136 default: |
|
137 { |
|
138 __ASSERT_DEBUG( EFalse, Panic( EESMRViewerCtrlInvalidEntryType ) ); |
|
139 } |
|
140 } |
|
141 |
|
142 return type; |
|
143 } |
|
144 |
|
145 /** |
|
146 * Creates calendar entry |
|
147 * @param required parameters for creating an entry |
|
148 * @return CCalEntry Created entry. |
|
149 */ |
|
150 CCalEntry* CreateEntryL( |
|
151 CCalEntry::TType aType, |
|
152 const TDesC8& aUid, |
|
153 CCalEntry::TMethod aMethod, |
|
154 CalCommon::TRecurrenceRange aRange ) |
|
155 { |
|
156 HBufC8* guid = aUid.AllocLC(); |
|
157 CCalEntry* entry = CCalEntry::NewL( aType, guid, aMethod, aRange ); |
|
158 CleanupStack::Pop( guid ); |
|
159 |
|
160 return entry; |
|
161 } |
|
162 |
|
163 /** |
|
164 * Converts to-do specific priority to normal priority |
|
165 * @param Calendar entry, which priority is converted |
|
166 * @return The converted priority |
|
167 */ |
|
168 TInt ConvertTodoPriorityToNormalL( const CCalEntry& entry ) |
|
169 { |
|
170 FUNC_LOG; |
|
171 TInt priority( 0 ); |
|
172 if( entry.PriorityL() == EFSCalenTodoPriorityHigh ) |
|
173 { |
|
174 priority = EFSCalenMRPriorityHigh; |
|
175 } |
|
176 |
|
177 else if( entry.PriorityL() == EFSCalenTodoPriorityNormal ) |
|
178 { |
|
179 priority = EFSCalenMRPriorityNormal; |
|
180 } |
|
181 |
|
182 else if( entry.PriorityL() == EFSCalenTodoPriorityLow ) |
|
183 { |
|
184 priority = EFSCalenMRPriorityLow; |
|
185 } |
|
186 |
|
187 else |
|
188 { |
|
189 // Priority unknown, let's set it to normal then |
|
190 priority = EFSCalenMRPriorityNormal; |
|
191 } |
|
192 |
|
193 return priority; |
|
194 } |
|
195 |
|
196 /** |
|
197 * Converts normal priority to to-do specific priority |
|
198 * @param Calendar entry, which priority is converted |
|
199 * @return The converted priority |
|
200 */ |
|
201 TInt ConvertNormalPriorityToTodoL( const CCalEntry& entry ) |
|
202 { |
|
203 FUNC_LOG; |
|
204 TInt priority( 0 ); |
|
205 if( entry.PriorityL() == EFSCalenMRPriorityHigh ) |
|
206 { |
|
207 priority = EFSCalenTodoPriorityHigh; |
|
208 } |
|
209 |
|
210 else if( entry.PriorityL() == EFSCalenMRPriorityNormal ) |
|
211 { |
|
212 priority = EFSCalenTodoPriorityNormal; |
|
213 } |
|
214 |
|
215 else if( entry.PriorityL() == EFSCalenMRPriorityLow ) |
|
216 { |
|
217 priority = EFSCalenTodoPriorityLow; |
|
218 } |
|
219 |
|
220 else |
|
221 { |
|
222 // Priority unknown, let's set it to normal then |
|
223 priority = EFSCalenMRPriorityNormal; |
|
224 } |
|
225 |
|
226 return priority; |
102 } |
227 } |
103 |
228 |
104 } // namespace |
229 } // namespace |
105 |
230 |
106 // ============================ MEMBER FUNCTIONS =============================== |
231 // ============================ MEMBER FUNCTIONS =============================== |
322 FUNC_LOG; |
451 FUNC_LOG; |
323 |
452 |
324 } |
453 } |
325 |
454 |
326 // ----------------------------------------------------------------------------- |
455 // ----------------------------------------------------------------------------- |
|
456 // CESMRViewerController::PolicyProvider |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 MMRPolicyProvider& CESMRViewerController::PolicyProvider() const |
|
460 { |
|
461 return *iPolicyMgr; |
|
462 } |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // CESMRViewerController::EntryL |
|
466 // ----------------------------------------------------------------------------- |
|
467 // |
|
468 MESMRCalEntry* CESMRViewerController::EntryL() |
|
469 { |
|
470 return &iEntryProcessor->ESMREntryL(); |
|
471 } |
|
472 |
|
473 // ----------------------------------------------------------------------------- |
327 // CESMRViewerController::ProcessCommandWithResultInternalL |
474 // CESMRViewerController::ProcessCommandWithResultInternalL |
328 // ----------------------------------------------------------------------------- |
475 // ----------------------------------------------------------------------------- |
329 // |
476 // |
330 TInt CESMRViewerController::ProcessCommandWithResultInternalL( |
477 TInt CESMRViewerController::ProcessCommandWithResultInternalL( |
331 TInt aCommandId ) |
478 TInt aCommandId ) |
332 { |
479 { |
333 FUNC_LOG; |
480 FUNC_LOG; |
334 |
481 |
|
482 TInt ret = ProcessDefaultCommandL( aCommandId ); |
|
483 |
|
484 if ( ret == KErrNotSupported ) |
|
485 { |
|
486 ret = ProcessMeetingRequestCommandL( aCommandId ); |
|
487 } |
|
488 |
|
489 return ret; |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CESMRViewerController::ProcessDefaultCommandL |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 TInt CESMRViewerController::ProcessDefaultCommandL( TInt aCommandId ) |
|
497 { |
|
498 FUNC_LOG; |
335 |
499 |
336 TESMRCommand command = static_cast<TESMRCommand>(aCommandId); |
500 TESMRCommand command = static_cast<TESMRCommand>(aCommandId); |
337 TBool needToProcessOutputParams( ETrue ); |
501 TBool needToProcessOutputParams( ETrue ); |
338 MESMRMeetingRequestEntry& entry = iEntryProcessor->ESMREntryL(); |
502 |
|
503 MESMRCalEntry& entry = iEntryProcessor->ESMREntryL(); |
|
504 TInt ret = KErrNone; |
|
505 |
|
506 MESMRCalDbMgr& dbMgr = entry.GetDBMgr(); |
|
507 switch( aCommandId ) |
|
508 { |
|
509 case EESMRCmdSaveMR: // Saves Entry |
|
510 case EESMRCmdCalEntryUISave: |
|
511 { |
|
512 // If we are editing an existing entry. |
|
513 if ( entry.IsStoredL() ) |
|
514 { |
|
515 // If entry is type changed. |
|
516 if ( entry.IsEntryTypeChangedL() ) |
|
517 { |
|
518 // If entry is type changed, delete the old entry first |
|
519 // from db ... |
|
520 |
|
521 CCalEntry* lastStoredEntry = |
|
522 dbMgr.FetchEntryL( |
|
523 entry.Entry().UidL(), |
|
524 entry.Entry().RecurrenceIdL() ); |
|
525 ASSERT( lastStoredEntry ); |
|
526 CleanupStack::PushL( lastStoredEntry ); |
|
527 |
|
528 if( CCalenInterimUtils2::IsMeetingRequestL( |
|
529 *lastStoredEntry ) ) |
|
530 { |
|
531 // Last stored entry was MR. If MR is sent, it needs to be |
|
532 // also cancelled before deleting |
|
533 CancelAndDeleteMRInEntryTypeChangeL( |
|
534 *lastStoredEntry,dbMgr ); |
|
535 } |
|
536 else |
|
537 { |
|
538 // Use right taskExtension |
|
539 CESMRTaskFactory* taskFactory = CESMRTaskFactory::NewL( |
|
540 MapType( *lastStoredEntry ), |
|
541 dbMgr ); |
|
542 CleanupStack::PushL( taskFactory ); |
|
543 |
|
544 MESMRTaskExtension* taskExtension = |
|
545 CESMRTaskExtenstionImpl::NewL( *taskFactory ); |
|
546 CleanupDeletePushL( taskExtension ); |
|
547 |
|
548 taskExtension->DeleteEntryFromLocalDBL( |
|
549 EESMRCmdCalEntryUIDelete, |
|
550 entry ); |
|
551 |
|
552 CleanupStack::PopAndDestroy( taskExtension ); |
|
553 CleanupStack::PopAndDestroy( taskFactory ); |
|
554 } |
|
555 |
|
556 // ... and then store the new (edited) entry to db. |
|
557 iTaskExt->StoreEntryToLocalDBL( |
|
558 command, |
|
559 entry ); |
|
560 |
|
561 CleanupStack::PopAndDestroy( lastStoredEntry ); |
|
562 } |
|
563 |
|
564 // If we are saving entry that previously existed in |
|
565 // different db. |
|
566 else if ( dbMgr.EntryViewL( entry.Entry() ) != NULL |
|
567 && dbMgr.EntryViewL( entry.Entry() ) != dbMgr.EntryView() ) |
|
568 { |
|
569 iTaskExt->MoveEntryToCurrentDBL( command, entry ); |
|
570 } |
|
571 |
|
572 // And if none of the above conditions apply, we are just editing |
|
573 // an entry and want to save it. |
|
574 else |
|
575 { |
|
576 iTaskExt->StoreEntryToLocalDBL( |
|
577 command, |
|
578 entry ); |
|
579 } |
|
580 } |
|
581 |
|
582 // Store new entry to db. |
|
583 else |
|
584 { |
|
585 iTaskExt->StoreEntryToLocalDBL( |
|
586 command, |
|
587 entry ); |
|
588 } |
|
589 } |
|
590 break; |
|
591 |
|
592 case EESMRCmdCalEntryUIDelete: // Deletes Entry |
|
593 { |
|
594 iTaskExt->DeleteEntryFromLocalDBL( |
|
595 command, |
|
596 entry ); |
|
597 |
|
598 } |
|
599 break; |
|
600 |
|
601 case EESMRCmdEdit: // Edit MR |
|
602 case EESMRCmdEditLocal: // Locally edit meeting request |
|
603 case EESMRCmdCalEntryUIEdit: // Edit calendar entries |
|
604 { |
|
605 iEntryProcessor->SwitchProcessorToModeL( EMRProcessorModeEdit ); |
|
606 iPolicyMgr->PushPolicyL(); |
|
607 LaunchUIL(); |
|
608 |
|
609 // No need to process parameters because the view is closed |
|
610 // and editing view has processed to parameters |
|
611 needToProcessOutputParams = EFalse; |
|
612 iPolicyMgr->PopPolicy(); |
|
613 |
|
614 iEntryProcessor->SwitchProcessorToModeL( EMRProcessorModeView ); |
|
615 } |
|
616 break; |
|
617 |
|
618 case EESMRCmdCalEntryUISend: // Send calendar entry item |
|
619 case EESMRCmdCalEntryUIAddParticipants: // Add participants to meeting item |
|
620 { |
|
621 ASSERT( EFalse ); // TODO: implement when tasks are ready |
|
622 } |
|
623 break; |
|
624 |
|
625 case EESMRCmdEditorInitializationComplete: |
|
626 { |
|
627 if ( iCallback.IsCommandAvailable( EESMRCmdEditorInitializationComplete ) ) |
|
628 { |
|
629 iCallback.ProcessCommandL( EESMRCmdEditorInitializationComplete ); |
|
630 } |
|
631 break; |
|
632 } |
|
633 |
|
634 case EMRCommandSwitchToMR: |
|
635 case EMRCommandSwitchToMeeting: |
|
636 case EMRCommandSwitchToMemo: |
|
637 case EMRCommandSwitchToAnniversary: |
|
638 case EMRCommandSwitchToTodo: |
|
639 { |
|
640 ChangeEntryTypeL( aCommandId ); |
|
641 needToProcessOutputParams = EFalse; |
|
642 } |
|
643 break; |
|
644 |
|
645 /* |
|
646 case EMRLaunchAttachmentsView: |
|
647 case EMRViewAttachmentInCorrespondingApp: |
|
648 { |
|
649 iCallback.ProcessCommandL( command ); |
|
650 } |
|
651 break; |
|
652 */ |
|
653 case EESMRCmdTodoMarkAsDone: |
|
654 { |
|
655 iTaskExt->MarkTodoAsDoneL( command, |
|
656 iEntryProcessor->ESMREntryL() ); |
|
657 } |
|
658 break; |
|
659 |
|
660 case EESMRCmdTodoMarkAsNotDone: |
|
661 { |
|
662 iTaskExt->MarkTodoAsNotDoneL( command, |
|
663 iEntryProcessor->ESMREntryL() ); |
|
664 } |
|
665 break; |
|
666 |
|
667 default: |
|
668 ret = KErrNotSupported; |
|
669 needToProcessOutputParams = EFalse; |
|
670 break; |
|
671 } |
|
672 |
|
673 if ( needToProcessOutputParams ) |
|
674 { |
|
675 iEntryProcessor->ProcessOutputParametersL( |
|
676 iOutParams, |
|
677 command ); |
|
678 } |
|
679 |
|
680 |
|
681 return ret; |
|
682 } |
|
683 |
|
684 // ----------------------------------------------------------------------------- |
|
685 // CESMRViewerController::ProcessMeetingRequestCommandL |
|
686 // ----------------------------------------------------------------------------- |
|
687 // |
|
688 TInt CESMRViewerController::ProcessMeetingRequestCommandL( TInt aCommandId ) |
|
689 { |
|
690 FUNC_LOG; |
|
691 |
|
692 TESMRCommand command = static_cast<TESMRCommand>(aCommandId); |
|
693 TBool needToProcessOutputParams( ETrue ); |
|
694 |
|
695 MESMRCalEntry* tmpEntry = &iEntryProcessor->ESMREntryL(); |
|
696 |
|
697 ASSERT( tmpEntry->Type() == EESMREventTypeMeetingRequest ); |
|
698 |
|
699 if ( tmpEntry->Type() != EESMREventTypeMeetingRequest ) |
|
700 { |
|
701 User::Leave( KErrNotSupported ); |
|
702 } |
|
703 |
|
704 MESMRMeetingRequestEntry& entry( *static_cast<MESMRMeetingRequestEntry*>( tmpEntry ) ); |
|
705 MESMRCalDbMgr& dbMgr = entry.GetDBMgr(); |
339 |
706 |
340 switch( aCommandId ) |
707 switch( aCommandId ) |
341 { |
708 { |
342 case EESMRCmdSendMR: // Send Meeting request |
709 case EESMRCmdSendMR: // Send Meeting request |
343 case EESMRCmdSendMRUpdate: // Send MR update |
710 case EESMRCmdSendMRUpdate: // Send MR update |
344 { |
711 { |
345 entry.ConfirmEntryL(); |
712 entry.ConfirmEntryL(); |
|
713 |
|
714 if( entry.IsStoredL() ) |
|
715 { |
|
716 if( entry.IsEntryTypeChangedL() || |
|
717 ( ( dbMgr.EntryViewL( entry.Entry() ) != NULL ) && |
|
718 ( dbMgr.EntryViewL( entry.Entry() ) != dbMgr.EntryView() ) ) ) |
|
719 { |
|
720 if(!entry.IsEntryTypeChangedL()) |
|
721 { |
|
722 entry.SetSendCanellationAvailable( EFalse ); |
|
723 } |
|
724 iTaskExt->DeleteEntryFromLocalDBL( |
|
725 EESMRCmdDeleteMR, |
|
726 entry ); |
|
727 } |
|
728 } |
346 iTaskExt->SendAndStoreMRL( |
729 iTaskExt->SendAndStoreMRL( |
347 command, |
730 command, |
348 entry ); |
731 entry ); |
349 } |
732 } |
350 break; |
733 break; |
351 |
734 |
352 case EESMRCmdAcceptMR: // Accept received MR |
735 case EESMRCmdAcceptMR: // Accept received MR |
353 case EESMRCmdTentativeMR: // Tentatively accept MR |
736 case EESMRCmdTentativeMR: // Tentatively accept MR |
354 case EESMRCmdDeclineMR: // Decline MR |
737 case EESMRCmdDeclineMR: // Decline MR |
355 |
738 { |
356 { |
739 entry.ConfirmEntryL(); |
357 if ( entry.IsRecurrentEventL() ) |
740 iTaskExt->SendAndStoreResponseL( |
358 { |
741 command, |
359 entry.SetModifyingRuleL(MESMRCalEntry::EESMRAllInSeries); |
742 entry ); |
360 } |
|
361 |
|
362 entry.ConfirmEntryL(); |
|
363 iTaskExt->SendAndStoreResponseL(command,entry ); |
|
364 |
|
365 if ( entry.IsOpenedFromMail() ) |
|
366 { |
|
367 // Triggering mail delete command also |
|
368 needToProcessOutputParams = EFalse; |
|
369 iCallback.ProcessCommandL( EESMRCmdMailDelete ); |
|
370 } |
|
371 } |
743 } |
372 break; |
744 break; |
373 |
745 |
374 case EESMRAcceptWithoutAttachmentCheck: |
746 case EESMRAcceptWithoutAttachmentCheck: |
375 case EESMRTentativeWithoutAttachmentCheck: |
747 case EESMRTentativeWithoutAttachmentCheck: |
411 iCallback.ProcessCommandL( aCommandId ); |
775 iCallback.ProcessCommandL( aCommandId ); |
412 } |
776 } |
413 } |
777 } |
414 break; |
778 break; |
415 |
779 |
416 case EESMRCmdEdit: // Edit MR |
780 case EESMRCmdViewTrack: |
417 case EESMRCmdEditLocal: // Locally edit meeting request |
781 { |
418 { |
782 TESMRViewMode viewMode = iEntryProcessor->ScenarioData().iViewMode; |
419 iEntryProcessor->SwitchToEditL(); |
783 // iEntryProcessor->SwitchToTrackL(); |
|
784 iEntryProcessor->SwitchProcessorToModeL( EMRProcessorModeTrack ); |
420 iPolicyMgr->PushPolicyL(); |
785 iPolicyMgr->PushPolicyL(); |
421 LaunchUIL(); |
786 LaunchUIL(); |
422 |
787 |
423 // No need to process parameters because the view is closed |
|
424 // and editing view has processed to parameters |
|
425 needToProcessOutputParams = EFalse; |
|
426 iPolicyMgr->PopPolicy(); |
|
427 iEntryProcessor->SwitchToViewL(); |
|
428 } |
|
429 break; |
|
430 case EESMRCmdViewTrack: |
|
431 { |
|
432 TESMRViewMode viewMode = iEntryProcessor->ScenarioData().iViewMode; |
|
433 iEntryProcessor->SwitchToTrackL(); |
|
434 iPolicyMgr->PushPolicyL(); |
|
435 LaunchUIL(); |
|
436 |
|
437 //go back to original view depending on where we came from |
788 //go back to original view depending on where we came from |
438 if (viewMode == EESMREditMR) |
789 if (viewMode == EESMREditMR) |
439 { |
790 { |
440 iEntryProcessor->SwitchToEditL(); |
791 //iEntryProcessor->SwitchToEditL(); |
|
792 iEntryProcessor->SwitchProcessorToModeL( EMRProcessorModeEdit ); |
441 } |
793 } |
442 else |
794 else |
443 { |
795 { |
444 iEntryProcessor->SwitchToViewL(); |
796 // iEntryProcessor->SwitchToViewL(); |
|
797 iEntryProcessor->SwitchProcessorToModeL( EMRProcessorModeView ); |
445 } |
798 } |
446 |
799 |
447 LaunchUIL(); |
800 LaunchUIL(); |
448 iPolicyMgr->PopPolicy(); |
801 iPolicyMgr->PopPolicy(); |
449 } |
802 } |
450 break; |
803 break; |
451 case EESMRCmdForwardAsMeeting: // Forward MR as meeting |
804 case EESMRCmdForwardAsMeeting: // Forward MR as meeting |
452 { |
805 { |
453 iEntryProcessor->SwitchToForwardL(); |
806 // iEntryProcessor->SwitchToForwardL(); |
|
807 iEntryProcessor->SwitchProcessorToModeL( EMRProcessorModeForward ); |
454 iPolicyMgr->PushPolicyL(); |
808 iPolicyMgr->PushPolicyL(); |
455 LaunchUIL(); |
809 LaunchUIL(); |
456 iPolicyMgr->PopPolicy(); |
810 iPolicyMgr->PopPolicy(); |
457 iEntryProcessor->SwitchToViewL(); |
811 // iEntryProcessor->SwitchToViewL(); |
|
812 iEntryProcessor->SwitchProcessorToModeL( EMRProcessorModeView ); |
458 } |
813 } |
459 break; |
814 break; |
460 |
815 |
461 case EESMRCmdForwardAsMail: // Forward MR as mail |
816 case EESMRCmdForwardAsMail: // Forward MR as mail |
462 { |
817 { |
543 iEntryProcessor->ProcessOutputParametersL( |
887 iEntryProcessor->ProcessOutputParametersL( |
544 iOutParams, |
888 iOutParams, |
545 command ); |
889 command ); |
546 } |
890 } |
547 |
891 |
548 |
|
549 return KErrNone; |
892 return KErrNone; |
550 } |
893 } |
551 |
894 |
552 // ----------------------------------------------------------------------------- |
895 // ----------------------------------------------------------------------------- |
|
896 // CESMRViewerController::ChangeEntryTypeL |
|
897 // ----------------------------------------------------------------------------- |
|
898 // |
|
899 void CESMRViewerController::ChangeEntryTypeL( TInt aCommandId ) |
|
900 { |
|
901 TESMRCalendarEventType type = EESMREventTypeNone; |
|
902 |
|
903 switch ( aCommandId ) |
|
904 { |
|
905 case EMRCommandSwitchToMR: |
|
906 { |
|
907 type = EESMREventTypeMeetingRequest; |
|
908 break; |
|
909 } |
|
910 |
|
911 case EMRCommandSwitchToMeeting: |
|
912 { |
|
913 type = EESMREventTypeAppt; |
|
914 break; |
|
915 } |
|
916 |
|
917 case EMRCommandSwitchToMemo: |
|
918 { |
|
919 type = EESMREventTypeEEvent; |
|
920 break; |
|
921 } |
|
922 |
|
923 case EMRCommandSwitchToAnniversary: |
|
924 { |
|
925 type = EESMREventTypeEAnniv; |
|
926 break; |
|
927 } |
|
928 |
|
929 case EMRCommandSwitchToTodo: |
|
930 { |
|
931 type = EESMREventTypeETodo; |
|
932 break; |
|
933 } |
|
934 |
|
935 default: |
|
936 { |
|
937 break; |
|
938 } |
|
939 } |
|
940 |
|
941 // Original entry is needed for creating new comparative entry |
|
942 CCalEntry* originalEntry = |
|
943 ESMRHelper::CopyEntryL( |
|
944 iEntryProcessor->ESMREntryL().OriginalEntry(), |
|
945 iEntryProcessor->ESMREntryL().OriginalEntry().MethodL(), |
|
946 ESMRHelper::ECopyFull ); |
|
947 |
|
948 CleanupStack::PushL( originalEntry ); |
|
949 |
|
950 // Create a new entry by cloning the existing entry. |
|
951 // This also does the type conversion and judges what |
|
952 // entry information will be copied from the old entry |
|
953 // to the new entry |
|
954 CCalEntry* newEntry = |
|
955 iEntryProcessor->ESMREntryL().CloneEntryLC( |
|
956 MESMRCalEntry::TESMRCalEntryType( type ) ); |
|
957 |
|
958 iESMRUtils->CreateExtensionsL( type ); |
|
959 |
|
960 iEntryProcessor = |
|
961 static_cast<CMREntryProcessor*>( |
|
962 iESMRUtils->ExtensionL( |
|
963 TUid::Uid( KESMRMREntryProcessorUid ) ) ); |
|
964 |
|
965 iPolicyMgr = |
|
966 static_cast<CESMRPolicyManager*>( |
|
967 iESMRUtils->ExtensionL( |
|
968 TUid::Uid( KESMRPolicyMgrUid ) ) ); |
|
969 |
|
970 iTaskExt = |
|
971 static_cast<MESMRTaskExtension*>( |
|
972 iESMRUtils->ExtensionL( |
|
973 TUid::Uid( KESMRTaskExtensionUid ) ) ); |
|
974 |
|
975 // Process entry |
|
976 iEntryProcessor->ResetL(); |
|
977 iEntryProcessor->ProcessL( &iInParams, *newEntry, EFalse, ETrue ); |
|
978 |
|
979 if ( iInParams.iEditorMode == MAgnEntryUi::EViewEntry ) |
|
980 { |
|
981 // If user has been viewing original entry, switch processor to editor. |
|
982 iEntryProcessor->SwitchProcessorToModeL( EMRProcessorModeEdit ); |
|
983 } |
|
984 |
|
985 // Resolve new policy |
|
986 iPolicyMgr->ResolvePolicyL( iEntryProcessor->ScenarioData(), |
|
987 iEntryProcessor->ESMREntryL(), |
|
988 NULL ); |
|
989 |
|
990 if ( iCalEntry ) |
|
991 { |
|
992 delete iCalEntry; |
|
993 } |
|
994 |
|
995 iCalEntry = newEntry; |
|
996 CleanupStack::Pop( newEntry ); |
|
997 newEntry = NULL; |
|
998 |
|
999 // Comparative entry needs to be updated also, otherwise |
|
1000 // type changed entry's saving won't function correctly |
|
1001 UpdateComparativeEntryInTypeChangeL( *originalEntry ); |
|
1002 |
|
1003 iEntryProcessor->ESMREntryL().SetTypeChanged( ETrue ); |
|
1004 |
|
1005 CleanupStack::PopAndDestroy( originalEntry ); |
|
1006 } |
|
1007 |
|
1008 // ----------------------------------------------------------------------------- |
553 // CESMRViewerController::LaunchUIL |
1009 // CESMRViewerController::LaunchUIL |
554 // ----------------------------------------------------------------------------- |
1010 // ----------------------------------------------------------------------------- |
555 // |
1011 // |
556 void CESMRViewerController::LaunchUIL() |
1012 void CESMRViewerController::LaunchUIL() |
557 { |
1013 { |
558 FUNC_LOG; |
1014 FUNC_LOG; |
559 MESMRMeetingRequestEntry& entry = iEntryProcessor->ESMREntryL(); |
|
560 |
|
561 iPolicyMgr->ResolvePolicyL( |
1015 iPolicyMgr->ResolvePolicyL( |
562 iEntryProcessor->ScenarioData(), |
1016 iEntryProcessor->ScenarioData(), |
563 entry, |
1017 iEntryProcessor->ESMREntryL(), |
564 NULL ); // Passing NULL --> Default policy resolver is used |
1018 NULL ); // Passing NULL --> Default policy resolver is used |
565 |
1019 |
566 MESMRUiBase* uibase = |
1020 MESMRUiBase* uibase = |
567 iGuiFactory->CreateUIL( |
1021 iGuiFactory->CreateUIL( |
568 &iPolicyMgr->CurrentPolicy(), |
1022 *this, |
569 entry, |
|
570 *this ); |
1023 *this ); |
571 |
1024 |
572 TInt retValue = uibase->ExecuteViewLD(); |
1025 TInt retValue = uibase->ExecuteViewLD(); |
573 TBool openedFromMail( entry.IsOpenedFromMail() ); |
1026 |
574 |
|
575 if ( retValue == EAknCmdExit ) |
1027 if ( retValue == EAknCmdExit ) |
576 { |
1028 { |
577 if ( openedFromMail ) |
1029 MESMRCalEntry* calEntry = &iEntryProcessor->ESMREntryL(); |
578 { |
1030 |
579 // Need to communicate with FS Email how this is |
1031 if( CCalenInterimUtils2::IsMeetingRequestL( calEntry->Entry() ) ) |
580 // indicated to FS EMail UI application |
1032 { |
581 } |
1033 // Cast safe, after we have identified the entry as mr |
582 else |
1034 MESMRMeetingRequestEntry& mrEntry( |
583 { |
1035 *static_cast< MESMRMeetingRequestEntry* >( calEntry ) ); |
584 CEikAppUi* appUi = |
1036 |
585 CEikonEnv::Static()->EikAppUi(); // codescanner::eikonenvstatic |
1037 if( mrEntry.IsOpenedFromMail() ) |
586 // Exit application |
1038 { |
587 static_cast<MEikCommandObserver*>(appUi)->ProcessCommandL(EAknCmdExit); |
1039 CEikAppUi* appUi = |
588 } |
1040 CEikonEnv::Static()->EikAppUi(); // codescanner::eikonenvstatic |
589 } |
1041 // Exit application |
|
1042 static_cast<MEikCommandObserver*>( appUi )->ProcessCommandL( |
|
1043 EAknCmdExit ); |
|
1044 } |
|
1045 else |
|
1046 { |
|
1047 // Let's inform via output parameters that |
|
1048 // exit is desired. |
|
1049 TMROutputParams* outputParams = |
|
1050 reinterpret_cast< TMROutputParams* >( iOutParams.iSpare ); |
|
1051 outputParams->iCommand = EMRDialogOptionsMenuExit; |
|
1052 } |
|
1053 } |
|
1054 else |
|
1055 { |
|
1056 // Let's inform via output parameters that |
|
1057 // exit is desired. |
|
1058 TMROutputParams* outputParams = |
|
1059 reinterpret_cast< TMROutputParams* >( iOutParams.iSpare ); |
|
1060 outputParams->iCommand = EMRDialogOptionsMenuExit; |
|
1061 } |
|
1062 } |
590 } |
1063 } |
591 |
1064 |
592 // ----------------------------------------------------------------------------- |
1065 // ----------------------------------------------------------------------------- |
593 // CESMRViewerController::LaunchCorrectOperationModeL |
1066 // CESMRViewerController::LaunchCorrectOperationModeL |
594 // ----------------------------------------------------------------------------- |
1067 // ----------------------------------------------------------------------------- |
607 { |
1080 { |
608 LaunchUIL(); |
1081 LaunchUIL(); |
609 } |
1082 } |
610 } |
1083 } |
611 |
1084 |
|
1085 // ----------------------------------------------------------------------------- |
|
1086 // CESMRViewerController::UpdateComparativeEntryInTypeChangeL |
|
1087 // ----------------------------------------------------------------------------- |
|
1088 // |
|
1089 void CESMRViewerController::UpdateComparativeEntryInTypeChangeL( |
|
1090 const CCalEntry& aOriginalEntry ) |
|
1091 { |
|
1092 /* |
|
1093 * This is needed because if user creates an entry and only type changes |
|
1094 * the entry, but does not input any data, we cannot save the entry. |
|
1095 */ |
|
1096 |
|
1097 CCalEntry& esmrEntry = iEntryProcessor->ESMREntryL().Entry(); |
|
1098 |
|
1099 TESMRCalendarEventType type = MapType( aOriginalEntry ); |
|
1100 |
|
1101 // Let's create new comparative entry based on the current |
|
1102 // type changed entry |
|
1103 CCalEntry* newComparativeEntry = CreateEntryL( |
|
1104 iCalEntry->EntryTypeL(), |
|
1105 iCalEntry->UidL(), |
|
1106 CCalEntry::EMethodNone, |
|
1107 CalCommon::EThisOnly ); |
|
1108 |
|
1109 CleanupStack::PushL( newComparativeEntry ); |
|
1110 |
|
1111 newComparativeEntry->CopyFromL( *iCalEntry ); |
|
1112 |
|
1113 // New comparative entry needs still data from original entry. |
|
1114 // Use case: |
|
1115 // - User opens entry to editor |
|
1116 // - User changes values |
|
1117 // - User changes entry type |
|
1118 // -> We need to determine if entry values have changed from the original |
|
1119 newComparativeEntry->SetSummaryL( |
|
1120 aOriginalEntry.SummaryL() ); |
|
1121 newComparativeEntry->SetLocationL( |
|
1122 aOriginalEntry.LocationL() ); |
|
1123 newComparativeEntry->SetDescriptionL( |
|
1124 aOriginalEntry.DescriptionL() ); |
|
1125 newComparativeEntry->SetReplicationStatusL( |
|
1126 aOriginalEntry.ReplicationStatusL() ); |
|
1127 |
|
1128 // If original and new entries are both appointments, |
|
1129 // then also start and end times can be copied from original entry |
|
1130 // to comparative entry |
|
1131 if( aOriginalEntry.EntryTypeL() == CCalEntry::EAppt && |
|
1132 esmrEntry.EntryTypeL() == CCalEntry::EAppt ) |
|
1133 { |
|
1134 newComparativeEntry->SetStartAndEndTimeL( |
|
1135 aOriginalEntry.StartTimeL(), |
|
1136 aOriginalEntry.EndTimeL() ); |
|
1137 } |
|
1138 |
|
1139 // Time stamp must be the same as in esmrEntry |
|
1140 newComparativeEntry->SetDTStampL( esmrEntry.DTStampL() ); |
|
1141 |
|
1142 // If neither the original entry, nor the new entry |
|
1143 // are To-do's, we can also copy the priority from |
|
1144 // the original entry, since priority value is then compatible |
|
1145 // between the old and the new entry types |
|
1146 if( aOriginalEntry.EntryTypeL() != CCalEntry::ETodo && |
|
1147 iCalEntry->EntryTypeL() != CCalEntry::ETodo ) |
|
1148 { |
|
1149 newComparativeEntry->SetPriorityL( |
|
1150 aOriginalEntry.PriorityL() ); |
|
1151 } |
|
1152 // One of the entries, original or new, are to-do's, |
|
1153 // so the priority value is not compatible between them. |
|
1154 // we need to convert that |
|
1155 else |
|
1156 { |
|
1157 if( aOriginalEntry.EntryTypeL() == CCalEntry::ETodo ) |
|
1158 { |
|
1159 newComparativeEntry->SetPriorityL( |
|
1160 ConvertTodoPriorityToNormalL( aOriginalEntry ) ); |
|
1161 } |
|
1162 else if( iCalEntry->EntryTypeL() == CCalEntry::ETodo ) |
|
1163 { |
|
1164 newComparativeEntry->SetPriorityL( |
|
1165 ConvertNormalPriorityToTodoL( aOriginalEntry ) ); |
|
1166 } |
|
1167 } |
|
1168 |
|
1169 // If new entry is meeting request, let's also |
|
1170 // copy the same phone owner to the comparative entry |
|
1171 if( iCalEntry->MethodL() == CCalEntry::EMethodRequest ) |
|
1172 { |
|
1173 CCalUser* temp = esmrEntry.OrganizerL(); // Ownership not transfered |
|
1174 CCalUser* organizer = ESMRHelper::CopyUserL( *temp ); |
|
1175 |
|
1176 newComparativeEntry->SetOrganizerL( organizer ); |
|
1177 newComparativeEntry->SetPhoneOwnerL( |
|
1178 newComparativeEntry->OrganizerL() ); |
|
1179 } |
|
1180 |
|
1181 // Attachment information is also needed from original entry |
|
1182 if( aOriginalEntry.AttachmentCountL() == 0 ) |
|
1183 { |
|
1184 // Original entry did not have attachments, so let's |
|
1185 // remove possible attachments from comparative entry also |
|
1186 TInt count = newComparativeEntry->AttachmentCountL(); |
|
1187 |
|
1188 // Attachments need to be deleted in reversed order |
|
1189 for( TInt i = ( count - 1 ); i == 0; --i ) |
|
1190 { |
|
1191 newComparativeEntry->DeleteAttachmentL( |
|
1192 *( newComparativeEntry->AttachmentL( i ) ) ); |
|
1193 } |
|
1194 |
|
1195 // If original entry does have attachments, we do nothing -> |
|
1196 // If original entry has attachments, it has been already saved |
|
1197 // and now type changed, which means that it needs to be saved |
|
1198 // anyway. |
|
1199 } |
|
1200 |
|
1201 iEntryProcessor->ESMREntryL().UpdateComparativeEntry( |
|
1202 newComparativeEntry ); // Takes ownership |
|
1203 |
|
1204 CleanupStack::Pop( newComparativeEntry ); |
|
1205 } |
|
1206 |
|
1207 // ----------------------------------------------------------------------------- |
|
1208 // CESMRViewerController::CancelAndDeleteMRInEntryTypeChangeL |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // |
|
1211 void CESMRViewerController::CancelAndDeleteMRInEntryTypeChangeL( |
|
1212 CCalEntry& aEntry, MESMRCalDbMgr& aDbMgr ) |
|
1213 { |
|
1214 FUNC_LOG; |
|
1215 // We need new task factor, processor and task extension |
|
1216 // for this temporary MR action. |
|
1217 CESMRTaskFactory* taskFactory = CESMRTaskFactory::NewL( |
|
1218 EESMREventTypeMeetingRequest, |
|
1219 aDbMgr ); |
|
1220 CleanupStack::PushL( taskFactory ); |
|
1221 |
|
1222 CMREntryProcessor* entryProcessor = CMREntryProcessor::NewL( |
|
1223 EESMREventTypeMeetingRequest, |
|
1224 aDbMgr ); |
|
1225 CleanupStack::PushL( entryProcessor ); |
|
1226 |
|
1227 MESMRTaskExtension* taskExtension = |
|
1228 CESMRTaskExtenstionImpl::NewL( *taskFactory ); |
|
1229 CleanupDeletePushL( taskExtension ); |
|
1230 |
|
1231 entryProcessor->ProcessL( &iInParams, aEntry, EFalse, ETrue ); |
|
1232 MESMRCalEntry& entry = entryProcessor->ESMREntryL(); |
|
1233 |
|
1234 // Cast safe, because entry is always MR |
|
1235 MESMRMeetingRequestEntry& mrEntry( |
|
1236 static_cast<MESMRMeetingRequestEntry&>( entry ) ); |
|
1237 |
|
1238 if ( EESMRRoleOrganizer == mrEntry.RoleL() ) |
|
1239 { |
|
1240 CCalEntry::TStatus status( mrEntry.Entry().StatusL() ); |
|
1241 if ( CCalEntry::ENullStatus != status ) |
|
1242 { |
|
1243 // We are changing entry type from MR to some other type |
|
1244 // And we have sent the MR invitation to attendees. |
|
1245 // We provide possibility for user to send |
|
1246 // cancellation message to attendees. |
|
1247 mrEntry.MarkMeetingCancelledL(); |
|
1248 |
|
1249 taskExtension->DeleteAndSendMRL( |
|
1250 EESMRCmdDeleteMR, |
|
1251 mrEntry ); |
|
1252 } |
|
1253 else |
|
1254 { |
|
1255 taskExtension->DeleteEntryFromLocalDBL( |
|
1256 EESMRCmdDeleteMR, |
|
1257 mrEntry ); |
|
1258 } |
|
1259 } |
|
1260 |
|
1261 CleanupStack::PopAndDestroy( taskExtension ); |
|
1262 CleanupStack::PopAndDestroy( entryProcessor ); |
|
1263 CleanupStack::PopAndDestroy( taskFactory ); |
|
1264 } |
|
1265 |
612 // End of File |
1266 // End of File |
613 |
|