|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ESMR esmviewer controller implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 //<cmail> |
|
20 #include "emailtrace.h" |
|
21 #include "cesmrpolicy.h" |
|
22 #include "esmrdef.h" |
|
23 #include "cesmrpolicymanager.h" |
|
24 //</cmail> |
|
25 |
|
26 #include "cesmrviewerctrl.h" |
|
27 #include "cesmrentryprocessor.h" |
|
28 #include "mesmrmeetingrequestentry.h" |
|
29 #include "mesmrtaskextension.h" |
|
30 //<cmail> |
|
31 #include "cesmruifactory.h" |
|
32 //</cmail> |
|
33 #include "mesmruibase.h" |
|
34 #include "tesmrinputparams.h" |
|
35 #include "esmrconfig.hrh" |
|
36 #include "cesmrconfirmationquery.h" |
|
37 #include "cesmrutils.h" |
|
38 #include "cesmrattachmentinfo.h" |
|
39 #include "cesmrcaluserutil.h" |
|
40 // <cmail> Removed profiling. </cmail> |
|
41 |
|
42 // Logging utilities |
|
43 |
|
44 // From System |
|
45 //<cmail> |
|
46 #include <CMRUtils.h> |
|
47 #include "esmrutilsapiext.h" |
|
48 //</cmail> |
|
49 #include <msvstd.h> |
|
50 #include <msvids.h> |
|
51 //<cmail> |
|
52 #include "FreestyleEmailUiConstants.h" |
|
53 //</cmail> |
|
54 #include <eikappui.h> |
|
55 #include <eikenv.h> |
|
56 |
|
57 // CONSTANTS |
|
58 /// Unnamed namespace for local definitions |
|
59 namespace { // codescanner::namespace |
|
60 |
|
61 #if defined(_DEBUG) |
|
62 |
|
63 // Definition for MR VIEWER ctrl panic text |
|
64 _LIT(KMRViewerCtrlPanicTxt, "ESMRViewerCtrl" ); |
|
65 |
|
66 // MR VIEWER ctrl panic codes |
|
67 enum TMRViewerCtrlPanicCode |
|
68 { |
|
69 EESMRViewerCtrlSyncher = 0, // Syncher is not created, |
|
70 EESMRViewerCtrlProcessor, |
|
71 EESMRViewerCtrlTaskExt, |
|
72 EESMRViewerCtrlPolicyMgr, |
|
73 }; |
|
74 |
|
75 void Panic(TMRViewerCtrlPanicCode aPanicCode) |
|
76 { |
|
77 User::Panic( KMRViewerCtrlPanicTxt, aPanicCode ); |
|
78 } |
|
79 |
|
80 #endif |
|
81 |
|
82 /** |
|
83 * Tests if entry contains attachments or not. |
|
84 * @param aEntry Reference to meeting request entry. |
|
85 * @return ETrue if entry contains attachments |
|
86 */ |
|
87 TBool ContainsAttachmentsL( |
|
88 MESMRMeetingRequestEntry& aEntry ) |
|
89 { |
|
90 TBool retValue( EFalse ); |
|
91 |
|
92 TESMRInputParams esmrInputParams; |
|
93 if ( aEntry.StartupParameters(esmrInputParams) ) |
|
94 { |
|
95 if ( esmrInputParams.iAttachmentInfo && |
|
96 esmrInputParams.iAttachmentInfo->AttachmentCount() ) |
|
97 { |
|
98 retValue = ETrue; |
|
99 } |
|
100 } |
|
101 return retValue; |
|
102 } |
|
103 |
|
104 } // namespace |
|
105 |
|
106 // ============================ MEMBER FUNCTIONS =============================== |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CESMRViewerController::CESMRViewerController |
|
110 // C++ default constructor can NOT contain any code, that |
|
111 // might leave. |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 CESMRViewerController::CESMRViewerController( |
|
115 RPointerArray<CCalEntry>& aEntries, |
|
116 const MAgnEntryUi::TAgnEntryUiInParams& aParams, |
|
117 MAgnEntryUi::TAgnEntryUiOutParams& aOutParams, |
|
118 MAgnEntryUiCallback& aCallback ) |
|
119 : iInParams( aParams ), |
|
120 iOutParams( aOutParams ), |
|
121 iCallback( aCallback ), |
|
122 iEntries( aEntries ) |
|
123 { |
|
124 FUNC_LOG; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CESMRViewerController::~CESMRViewerController |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 EXPORT_C CESMRViewerController::~CESMRViewerController() |
|
132 { |
|
133 FUNC_LOG; |
|
134 delete iESMRUtils; |
|
135 delete iCtrlSyncher; |
|
136 delete iGuiFactory; |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CESMRViewerController::NewL |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C CESMRViewerController* CESMRViewerController::NewL( |
|
144 const TDesC8& aMtmuid, |
|
145 RPointerArray<CCalEntry>& aEntries, |
|
146 const MAgnEntryUi::TAgnEntryUiInParams& aParams, |
|
147 MAgnEntryUi::TAgnEntryUiOutParams& aOutParams, |
|
148 MAgnEntryUiCallback& aCallback ) |
|
149 { |
|
150 FUNC_LOG; |
|
151 |
|
152 CESMRViewerController* self = |
|
153 new( ELeave ) CESMRViewerController( aEntries, |
|
154 aParams, |
|
155 aOutParams, |
|
156 aCallback ); |
|
157 |
|
158 CleanupStack::PushL( self ); |
|
159 self->ConstructL(aMtmuid); |
|
160 CleanupStack::Pop( self ); |
|
161 |
|
162 return self; |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CESMRViewerController::ConstructL |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CESMRViewerController::ConstructL(const TDesC8& /*aMtmUid */) |
|
170 { |
|
171 FUNC_LOG; |
|
172 // This will create ESMR UTILS. Initialization is asynchronous. |
|
173 // Competion is signaled via CESMRViewerController::HandleCalEngStatus. |
|
174 iESMRUtils = CESMRUtils::NewL( *this ); |
|
175 iESMRUtils->SessionSetupL( |
|
176 iInParams.iCalSession, |
|
177 iInParams.iMsgSession ); |
|
178 |
|
179 iGuiFactory = CESMRUiFactory::NewL(); |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CESMRViewerController::ExecuteL |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 EXPORT_C void CESMRViewerController::ExecuteL() |
|
187 { |
|
188 FUNC_LOG; |
|
189 |
|
190 iExecutionError = KErrNone; |
|
191 |
|
192 // Initialization waiter is needed because MR VIEWER user expects |
|
193 // MR VIEWER operation to be synchronous. |
|
194 iCtrlSyncher = new (ELeave) CActiveSchedulerWait; |
|
195 |
|
196 // MR UTILS calls CESMRViewerController::HandleCalEngStatus after init is |
|
197 // complete. CESMRViewerController::HandleCalEngStatus also sets |
|
198 // iExectionError if there occurs error during MR UTILS init. |
|
199 iCtrlSyncher->Start(); |
|
200 |
|
201 User::LeaveIfError( iExecutionError ); |
|
202 |
|
203 iEntryProcessor = |
|
204 static_cast<CESMREntryProcessor*>( |
|
205 iESMRUtils->ExtensionL( |
|
206 TUid::Uid(KESMRMREntryProcessorUid) ) ); |
|
207 |
|
208 iPolicyMgr = |
|
209 static_cast<CESMRPolicyManager*>( |
|
210 iESMRUtils->ExtensionL( |
|
211 TUid::Uid(KESMRPolicyMgrUid) ) ); |
|
212 |
|
213 iTaskExt = |
|
214 static_cast<MESMRTaskExtension*>( |
|
215 iESMRUtils->ExtensionL( |
|
216 TUid::Uid(KESMRTaskExtensionUid) ) ); |
|
217 |
|
218 // Check that all extensions are found |
|
219 if ( !iEntryProcessor || !iPolicyMgr || !iTaskExt ) |
|
220 { |
|
221 // All extensions are not found --> Leave |
|
222 User::Leave( KErrNotSupported ); |
|
223 } |
|
224 |
|
225 iEntryProcessor->ProcessL( |
|
226 &iInParams, |
|
227 &iEntries ); |
|
228 |
|
229 LaunchCorrectOperationModeL(); |
|
230 |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CESMRViewerController::IsCommandAvailable |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 TBool CESMRViewerController::IsCommandAvailable( TInt aCommandId ) |
|
238 { |
|
239 FUNC_LOG; |
|
240 |
|
241 |
|
242 TBool retValue( EFalse ); |
|
243 |
|
244 if ( KFSEmailUiUid == iInParams.iCallingApp ) |
|
245 { |
|
246 retValue = iCallback.IsCommandAvailable( aCommandId ); |
|
247 } |
|
248 |
|
249 |
|
250 return retValue; |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CESMRViewerController::ProcessCommandWithResultL |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 TInt CESMRViewerController::ProcessCommandWithResultL( TInt aCommandId ) |
|
258 { |
|
259 FUNC_LOG; |
|
260 |
|
261 TInt result = ProcessCommandWithResultInternalL(aCommandId); |
|
262 |
|
263 |
|
264 return result; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CESMRViewerController::ProcessCommandL |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CESMRViewerController::ProcessCommandL( TInt aCommandId ) |
|
272 { |
|
273 FUNC_LOG; |
|
274 |
|
275 ProcessCommandWithResultL( aCommandId ); |
|
276 |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CESMRViewerController::HandleCalEngStatus |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CESMRViewerController::HandleCalEngStatus( TMRUtilsCalEngStatus aStatus ) |
|
284 { |
|
285 FUNC_LOG; |
|
286 |
|
287 |
|
288 __ASSERT_DEBUG( iCtrlSyncher, Panic(EESMRViewerCtrlSyncher) ); |
|
289 |
|
290 if ( ENotReady == aStatus ) |
|
291 { |
|
292 // cal db is not ready |
|
293 iExecutionError = KErrNotReady; |
|
294 } |
|
295 else if (ENotAvailable == aStatus ) |
|
296 { |
|
297 // cal db cannot be found |
|
298 iExecutionError = KErrNotFound; |
|
299 } |
|
300 |
|
301 // <cmail> |
|
302 if ( iCtrlSyncher && |
|
303 iCtrlSyncher->IsStarted() && |
|
304 iCtrlSyncher->CanStopNow() ) |
|
305 // </cmail> |
|
306 { |
|
307 // Exection continues in CESMRViewerController::ExecuteL |
|
308 iCtrlSyncher->AsyncStop(); |
|
309 } |
|
310 |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CESMRViewerController::HandleOperation |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 void CESMRViewerController::HandleOperation( |
|
318 TInt /*aType*/, |
|
319 TInt /*aPercentageCompleted*/, |
|
320 TInt /*aStatus*/ ) |
|
321 { |
|
322 FUNC_LOG; |
|
323 |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CESMRViewerController::ProcessCommandWithResultInternalL |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 TInt CESMRViewerController::ProcessCommandWithResultInternalL( |
|
331 TInt aCommandId ) |
|
332 { |
|
333 FUNC_LOG; |
|
334 |
|
335 |
|
336 TESMRCommand command = static_cast<TESMRCommand>(aCommandId); |
|
337 TBool needToProcessOutputParams( ETrue ); |
|
338 MESMRMeetingRequestEntry& entry = iEntryProcessor->ESMREntryL(); |
|
339 |
|
340 switch( aCommandId ) |
|
341 { |
|
342 case EESMRCmdSendMR: // Send Meeting request |
|
343 case EESMRCmdSendMRUpdate: // Send MR update |
|
344 { |
|
345 entry.ConfirmEntryL(); |
|
346 iTaskExt->SendAndStoreMRL( |
|
347 command, |
|
348 entry ); |
|
349 } |
|
350 break; |
|
351 |
|
352 case EESMRCmdAcceptMR: // Accept received MR |
|
353 case EESMRCmdTentativeMR: // Tentatively accept MR |
|
354 case EESMRCmdDeclineMR: // Decline MR |
|
355 |
|
356 { |
|
357 if ( entry.IsRecurrentEventL() ) |
|
358 { |
|
359 entry.SetModifyingRuleL(MESMRCalEntry::EESMRAllInSeries); |
|
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 } |
|
372 break; |
|
373 |
|
374 case EESMRAcceptWithoutAttachmentCheck: |
|
375 case EESMRTentativeWithoutAttachmentCheck: |
|
376 case EESMRDeclineWithoutAttachmentCheck: |
|
377 { |
|
378 entry.ConfirmEntryL(); |
|
379 iTaskExt->SendAndStoreResponseL( |
|
380 command, |
|
381 entry ); |
|
382 } |
|
383 break; |
|
384 |
|
385 case EESMRCmdSaveMR: // Saves MR |
|
386 { |
|
387 iTaskExt->StoreMRToLocalDBL( |
|
388 command, |
|
389 entry ); |
|
390 } |
|
391 break; |
|
392 |
|
393 case EESMRCmdDeleteMR: // Deletes MR |
|
394 case EESMRCmdRemoveFromCalendar: // Removes MR from calendar |
|
395 case EESMRCmdMailDelete: // Mail specific delete command |
|
396 { |
|
397 if ( EESMRCmdDeleteMR == command || |
|
398 EESMRCmdMailDelete == command ) |
|
399 { |
|
400 entry.MarkMeetingCancelledL(); |
|
401 } |
|
402 |
|
403 iTaskExt->DeleteAndSendMRL( |
|
404 command, |
|
405 entry ); |
|
406 |
|
407 if ( entry.IsOpenedFromMail() ) |
|
408 { |
|
409 // Triggering mail delete command also |
|
410 needToProcessOutputParams = EFalse; |
|
411 iCallback.ProcessCommandL( aCommandId ); |
|
412 } |
|
413 } |
|
414 break; |
|
415 |
|
416 case EESMRCmdEdit: // Edit MR |
|
417 case EESMRCmdEditLocal: // Locally edit meeting request |
|
418 { |
|
419 iEntryProcessor->SwitchToEditL(); |
|
420 iPolicyMgr->PushPolicyL(); |
|
421 LaunchUIL(); |
|
422 |
|
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 |
|
438 if (viewMode == EESMREditMR) |
|
439 { |
|
440 iEntryProcessor->SwitchToEditL(); |
|
441 } |
|
442 else |
|
443 { |
|
444 iEntryProcessor->SwitchToViewL(); |
|
445 } |
|
446 |
|
447 LaunchUIL(); |
|
448 iPolicyMgr->PopPolicy(); |
|
449 } |
|
450 break; |
|
451 case EESMRCmdForwardAsMeeting: // Forward MR as meeting |
|
452 { |
|
453 iEntryProcessor->SwitchToForwardL(); |
|
454 iPolicyMgr->PushPolicyL(); |
|
455 LaunchUIL(); |
|
456 iPolicyMgr->PopPolicy(); |
|
457 iEntryProcessor->SwitchToViewL(); |
|
458 } |
|
459 break; |
|
460 |
|
461 case EESMRCmdForwardAsMail: // Forward MR as mail |
|
462 { |
|
463 if ( entry.IsOpenedFromMail() ) |
|
464 { |
|
465 needToProcessOutputParams = EFalse; |
|
466 iCallback.ProcessCommandL( |
|
467 EESMRCmdMailForwardAsMessage ); |
|
468 } |
|
469 else |
|
470 { |
|
471 iTaskExt->ForwardMRAsEmailL( |
|
472 command, |
|
473 entry ); |
|
474 } |
|
475 } |
|
476 break; |
|
477 |
|
478 case EESMRCmdReply: // Forward MR as mail |
|
479 case EESMRCmdReplyAll: //Flow through |
|
480 { |
|
481 if ( entry.IsOpenedFromMail() ) |
|
482 { |
|
483 TInt emailCommand( EESMRCmdMailReply ); |
|
484 if ( EESMRCmdReplyAll == aCommandId ) |
|
485 { |
|
486 emailCommand = EESMRCmdMailReplyAll; |
|
487 } |
|
488 needToProcessOutputParams = EFalse; |
|
489 iCallback.ProcessCommandL( |
|
490 emailCommand ); |
|
491 } |
|
492 else |
|
493 { |
|
494 iTaskExt->ReplyAsEmailL( |
|
495 command, |
|
496 entry ); |
|
497 } |
|
498 } |
|
499 break; |
|
500 |
|
501 // Email commands |
|
502 case EESMRCmdMailMarkUnread: |
|
503 case EESMRCmdMailMarkRead: |
|
504 case EESMRCmdMailForwardAsMessage: |
|
505 case EESMRCmdMailMoveMessage: |
|
506 case EESMRCmdMailCopyMessage: |
|
507 case EESMRCmdMailFlagMessage: |
|
508 case EESMRCmdMailComposeMessage: |
|
509 case EESMRCmdMailMessageDetails: |
|
510 case EESMRCmdMailPreviousMessage: |
|
511 case EESMRCmdMailNextMessage: |
|
512 case EESMRCmdMailMoveMessageToDrafts: |
|
513 case EESMRCmdOpenAttachment: |
|
514 case EESMRCmdOpenAttachmentView: |
|
515 // <cmail |
|
516 case EESMRCmdDownloadAttachment: |
|
517 case EESMRCmdDownloadAllAttachments: |
|
518 case EESMRCmdSaveAttachment: |
|
519 case EESMRCmdSaveAllAttachments: |
|
520 // </cmail> |
|
521 case EESMRCmdDownloadManager: |
|
522 { |
|
523 needToProcessOutputParams = EFalse; |
|
524 iCallback.ProcessCommandL( aCommandId ); |
|
525 } |
|
526 break; |
|
527 |
|
528 case EESMRCmdEditorInitializationComplete: |
|
529 { |
|
530 if ( iCallback.IsCommandAvailable( EESMRCmdEditorInitializationComplete ) ) |
|
531 { |
|
532 iCallback.ProcessCommandL( EESMRCmdEditorInitializationComplete ); |
|
533 } |
|
534 break; |
|
535 } |
|
536 |
|
537 default: |
|
538 User::Leave( KErrNotSupported ); |
|
539 } |
|
540 |
|
541 if ( needToProcessOutputParams ) |
|
542 { |
|
543 iEntryProcessor->ProcessOutputParametersL( |
|
544 iOutParams, |
|
545 command ); |
|
546 } |
|
547 |
|
548 |
|
549 return KErrNone; |
|
550 } |
|
551 |
|
552 // ----------------------------------------------------------------------------- |
|
553 // CESMRViewerController::LaunchUIL |
|
554 // ----------------------------------------------------------------------------- |
|
555 // |
|
556 void CESMRViewerController::LaunchUIL() |
|
557 { |
|
558 FUNC_LOG; |
|
559 MESMRMeetingRequestEntry& entry = iEntryProcessor->ESMREntryL(); |
|
560 |
|
561 iPolicyMgr->ResolvePolicyL( |
|
562 iEntryProcessor->ScenarioData(), |
|
563 entry, |
|
564 NULL ); // Passing NULL --> Default policy resolver is used |
|
565 |
|
566 MESMRUiBase* uibase = |
|
567 iGuiFactory->CreateUIL( |
|
568 &iPolicyMgr->CurrentPolicy(), |
|
569 entry, |
|
570 *this ); |
|
571 |
|
572 TInt retValue = uibase->ExecuteViewLD(); |
|
573 TBool openedFromMail( entry.IsOpenedFromMail() ); |
|
574 |
|
575 if ( retValue == EAknCmdExit ) |
|
576 { |
|
577 if ( openedFromMail ) |
|
578 { |
|
579 // Need to communicate with FS Email how this is |
|
580 // indicated to FS EMail UI application |
|
581 } |
|
582 else |
|
583 { |
|
584 CEikAppUi* appUi = |
|
585 CEikonEnv::Static()->EikAppUi(); // codescanner::eikonenvstatic |
|
586 // Exit application |
|
587 static_cast<MEikCommandObserver*>(appUi)->ProcessCommandL(EAknCmdExit); |
|
588 } |
|
589 } |
|
590 } |
|
591 |
|
592 // ----------------------------------------------------------------------------- |
|
593 // CESMRViewerController::LaunchCorrectOperationModeL |
|
594 // ----------------------------------------------------------------------------- |
|
595 // |
|
596 void CESMRViewerController::LaunchCorrectOperationModeL() |
|
597 { |
|
598 FUNC_LOG; |
|
599 TESMRInputParams* esmrInputParams = (TESMRInputParams*)(iInParams.iSpare); |
|
600 |
|
601 if ( esmrInputParams && |
|
602 EESMRCmdUndefined != esmrInputParams->iCommand ) |
|
603 { |
|
604 ProcessCommandWithResultL( esmrInputParams->iCommand ); |
|
605 } |
|
606 else |
|
607 { |
|
608 LaunchUIL(); |
|
609 } |
|
610 } |
|
611 |
|
612 // End of File |
|
613 |