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 entry processor implementation |
|
15 * Version : %version: e003sa40#13 % |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "emailtrace.h" |
|
22 #include "cesmrentryprocessor.h" |
|
23 #include "cesmrcaldbmgr.h" |
|
24 #include "cesmrmeetingrequestentry.h" |
|
25 #include "cesmrconflictchecker.h" |
|
26 #include "esmrhelper.h" |
|
27 #include "esmrinternaluid.h" |
|
28 #include "cesmrfsmailboxutils.h" |
|
29 |
|
30 //<cmail> |
|
31 #include "esmrdef.h" |
|
32 //</cmail> |
|
33 #include <e32std.h> |
|
34 #include <calentry.h> |
|
35 #include <calinstance.h> |
|
36 #include <calrrule.h> |
|
37 #include <caluser.h> |
|
38 #include <caltime.h> |
|
39 #include <CalenInterimUtils2.h> |
|
40 #include <cmrmailboxutils.h> |
|
41 #include <MAgnEntryUi.h> |
|
42 //<cmail> |
|
43 #include "FreestyleEmailUiConstants.h" |
|
44 #include "cesmrrecurrenceinfohandler.h" |
|
45 //</cmail> |
|
46 #include "esmrentryhelper.h" |
|
47 #include "tesmrinputparams.h" |
|
48 |
|
49 /// Unnamed namespace for local definitions |
|
50 namespace { |
|
51 |
|
52 // Definition for first item index |
|
53 const TInt KFirstEntryIndex = 0; |
|
54 |
|
55 // Definition for zero interval |
|
56 const TInt KZeroInterval = 0; |
|
57 |
|
58 #ifdef _DEBUG |
|
59 |
|
60 // Definition for module panic text |
|
61 _LIT( KESMRProcessorPanicTxt, "ESMREntryProcessor" ); |
|
62 |
|
63 /** |
|
64 * ESMREntryProcessor panic codes |
|
65 */ |
|
66 enum TESMREntryProcessorPanic |
|
67 { |
|
68 // Input entry array is empty |
|
69 EESMRProcessorEmptyEntryArray = 1, |
|
70 // Too many input entries |
|
71 EESMRProcessorTooManyEntries = 2, |
|
72 // entries are not processed |
|
73 EESMRProcessorEntriesNotProcessed, |
|
74 // View mode for policy resolving |
|
75 // cannot be check. |
|
76 EESMRProcessorCannotCheckViewMode, |
|
77 }; |
|
78 |
|
79 /** |
|
80 * Raises panic. |
|
81 * @param aPanic Panic code |
|
82 */ |
|
83 void Panic(TESMREntryProcessorPanic aPanic) |
|
84 { |
|
85 |
|
86 User::Panic( KESMRProcessorPanicTxt(), |
|
87 aPanic); |
|
88 } |
|
89 |
|
90 /** |
|
91 * Logs scenatio data |
|
92 * @param aData Reference to scenario data. |
|
93 */ |
|
94 void LogScenatioData( |
|
95 const TESMRScenarioData& /*aScenarioData*/ ) |
|
96 { |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 } |
|
102 |
|
103 #endif // _DEBUG |
|
104 |
|
105 /** |
|
106 * Cleanup operation for RPointerArray. |
|
107 * |
|
108 * @param aArray Pointer to RPointerArray. |
|
109 */ |
|
110 void CalEntryPointerArrayCleanup( TAny* aArray ) |
|
111 { |
|
112 RPointerArray<CCalEntry>* entryArray = |
|
113 static_cast<RPointerArray<CCalEntry>*>( aArray ); |
|
114 |
|
115 entryArray->ResetAndDestroy(); |
|
116 entryArray->Close(); |
|
117 } |
|
118 |
|
119 /** |
|
120 * Sets child entry's start and end time. |
|
121 * |
|
122 * @param aChild Reference to child entry |
|
123 * @param aParent Reference to parent entry |
|
124 * @param aChildEnd Child entry's start time |
|
125 */ |
|
126 void SetInstanceStartAndEndL( |
|
127 CCalEntry& aChild, |
|
128 const CCalEntry& aParent, |
|
129 const TCalTime& aChildStart ) |
|
130 { |
|
131 TTime parentStart( aParent.StartTimeL().TimeUtcL() ); |
|
132 TTime parentEnd( aParent.EndTimeL().TimeUtcL() ); |
|
133 TTime childStart( aChildStart.TimeUtcL() ); |
|
134 const TTime KNullTime( Time::NullTTime() ); |
|
135 |
|
136 if ( KNullTime == parentStart || |
|
137 KNullTime == parentEnd || |
|
138 KNullTime == childStart ) |
|
139 { |
|
140 // Invalid time --> Leaving |
|
141 User::Leave( KErrArgument ); |
|
142 } |
|
143 |
|
144 TTimeIntervalMicroSeconds duration( KZeroInterval ); |
|
145 duration = parentEnd.MicroSecondsFrom( parentStart ); |
|
146 TCalTime childEnd; |
|
147 childEnd.SetTimeUtcL( childStart + duration ); |
|
148 |
|
149 aChild.SetStartAndEndTimeL( aChildStart, childEnd ); |
|
150 } |
|
151 |
|
152 void CheckRepeatUntilValidityL( |
|
153 CCalEntry& aEntry, |
|
154 const TCalTime& aInstanceTime ) |
|
155 { |
|
156 |
|
157 if ( ESMREntryHelper::IsRepeatingMeetingL(aEntry) && |
|
158 !ESMREntryHelper::IsModifyingEntryL(aEntry) ) |
|
159 { |
|
160 TCalRRule originalRRule; |
|
161 if ( aEntry.GetRRuleL( originalRRule ) ) |
|
162 { |
|
163 TCalTime endTime = aEntry.EndTimeL(); |
|
164 TCalTime startTime = aEntry.StartTimeL(); |
|
165 |
|
166 TTimeIntervalMicroSeconds duration = |
|
167 endTime.TimeLocalL().MicroSecondsFrom( |
|
168 startTime.TimeLocalL() ); |
|
169 |
|
170 TTime instanceEndTime( aInstanceTime.TimeLocalL() ); |
|
171 instanceEndTime += duration; |
|
172 TCalTime repeatUntilTime = originalRRule.Until(); |
|
173 |
|
174 TDateTime repeat = repeatUntilTime.TimeLocalL().DateTime(); |
|
175 TDateTime instanceEndDatetime = instanceEndTime.DateTime(); |
|
176 |
|
177 if ( repeatUntilTime.TimeLocalL() < instanceEndTime ) |
|
178 { |
|
179 // reset the recurrence so, that the repeat until |
|
180 // time is included in repeat range. This is done, |
|
181 // because when setting the instance start and end |
|
182 // time, the CCalEntry implementation clears the |
|
183 // recurrence information if the end time is |
|
184 // after repeat until end time. |
|
185 // CCalEntry forces the repeat until time to be |
|
186 // same than last entry's start time when storing the |
|
187 // entry to db. Reason uknown. |
|
188 TCalRRule rRule; |
|
189 rRule.SetDtStart( originalRRule.DtStart() ); |
|
190 rRule.SetType( originalRRule.Type() ); |
|
191 |
|
192 TCalTime newUntil; |
|
193 newUntil.SetTimeLocalL( instanceEndTime ); |
|
194 rRule.SetUntil( newUntil ); |
|
195 rRule.SetInterval( originalRRule.Interval() ); |
|
196 aEntry.SetRRuleL( rRule ); |
|
197 } |
|
198 } |
|
199 } |
|
200 } |
|
201 |
|
202 } // namespace |
|
203 |
|
204 // ======== MEMBER FUNCTIONS ======== |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CESMREntryProcessor::CESMREntryProcessor |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 inline CESMREntryProcessor::CESMREntryProcessor( |
|
211 CMRMailboxUtils& aMRMailboxUtils, |
|
212 MESMRCalDbMgr& aDbMgr ) |
|
213 : iMRMailboxUtils( aMRMailboxUtils ), |
|
214 iDbMgr( aDbMgr ) |
|
215 { |
|
216 FUNC_LOG; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CESMREntryProcessor::~CESMREntryProcessor |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 EXPORT_C CESMREntryProcessor::~CESMREntryProcessor() |
|
224 { |
|
225 FUNC_LOG; |
|
226 delete iESMREntry; |
|
227 delete iMbUtils; |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // CESMREntryProcessor::ConstructL |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 void CESMREntryProcessor::ConstructL() |
|
235 { |
|
236 FUNC_LOG; |
|
237 iMbUtils = |
|
238 CESMRFsMailboxUtils::NewL( iMRMailboxUtils ); |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // CESMREntryProcessor::NewL |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 EXPORT_C CESMREntryProcessor* CESMREntryProcessor::NewL( |
|
246 CMRMailboxUtils& aMRMailboxUtils, |
|
247 MESMRCalDbMgr& aDbMgr ) |
|
248 { |
|
249 FUNC_LOG; |
|
250 |
|
251 CESMREntryProcessor* self = |
|
252 new (ELeave) CESMREntryProcessor( |
|
253 aMRMailboxUtils, aDbMgr ); |
|
254 CleanupStack::PushL( self ); |
|
255 self->ConstructL(); |
|
256 CleanupStack::Pop( self ); |
|
257 |
|
258 |
|
259 return self; |
|
260 } |
|
261 |
|
262 // --------------------------------------------------------------------------- |
|
263 // CESMREntryProcessor::ExtensionUid |
|
264 // --------------------------------------------------------------------------- |
|
265 // |
|
266 EXPORT_C TUid CESMREntryProcessor::ExtensionUid() |
|
267 { |
|
268 FUNC_LOG; |
|
269 return TUid::Uid( KESMRMREntryProcessorUid ); |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // CESMREntryProcessor::ProcessL |
|
274 // --------------------------------------------------------------------------- |
|
275 // |
|
276 EXPORT_C void CESMREntryProcessor::ProcessL( |
|
277 const MAgnEntryUi::TAgnEntryUiInParams* aParams, |
|
278 RPointerArray<CCalEntry>* aEntries ) |
|
279 { |
|
280 FUNC_LOG; |
|
281 |
|
282 iParams = aParams; |
|
283 ProcessL( aEntries ); |
|
284 CheckViewModeL(); |
|
285 |
|
286 if ( !IsDataOk() ) |
|
287 { |
|
288 // Data is not ok --> Leave |
|
289 User::Leave( KErrArgument ); |
|
290 } |
|
291 |
|
292 // Check mail parameters |
|
293 if ( iParams ) |
|
294 { |
|
295 CCalEntry* entry = &iESMREntry->Entry(); |
|
296 if(entry) |
|
297 { |
|
298 TBool recurrent(EFalse); |
|
299 recurrent = iESMREntry->IsRecurrentEventL(); |
|
300 |
|
301 if(recurrent) |
|
302 { |
|
303 if ( !ESMREntryHelper::IsModifyingEntryL(*entry) ) |
|
304 { |
|
305 iESMREntry->SetModifyingRuleL( MESMRMeetingRequestEntry::EESMRAllInSeries ); |
|
306 |
|
307 SetPhoneOwnerToOwnEntryL(); |
|
308 } |
|
309 } |
|
310 } |
|
311 } |
|
312 |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------------------------- |
|
316 // CESMREntryProcessor::ProcessL |
|
317 // --------------------------------------------------------------------------- |
|
318 // |
|
319 EXPORT_C void CESMREntryProcessor::ProcessL( |
|
320 RPointerArray<CCalEntry>* aEntries ) |
|
321 { |
|
322 FUNC_LOG; |
|
323 |
|
324 __ASSERT_DEBUG( aEntries->Count() > 0, |
|
325 Panic( EESMRProcessorEmptyEntryArray ) ); |
|
326 |
|
327 iMREntries = aEntries; |
|
328 |
|
329 // Set initial values to scenario data |
|
330 iScenData.iRole = EESMRRoleUndef; |
|
331 iScenData.iViewMode = EESMRViewUndef; |
|
332 iScenData.iCallingApp = EESMRAppUndef; |
|
333 |
|
334 SetPhoneOwnerL(); |
|
335 CreateESMREntryL(); |
|
336 CheckOrganizerL(); |
|
337 |
|
338 iESMREntry->SetModifyingRuleL( |
|
339 MESMRMeetingRequestEntry::EESMRThisOnly ); |
|
340 |
|
341 if ( iParams && MAgnEntryUi::ECreateNewEntry == iParams->iEditorMode ) |
|
342 { |
|
343 iESMREntry->SetDefaultValuesToEntryL(); |
|
344 } |
|
345 |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CESMREntryProcessor::ProcessL |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 EXPORT_C void CESMREntryProcessor::ProcessL( |
|
353 CCalInstance& aInstance ) |
|
354 { |
|
355 FUNC_LOG; |
|
356 |
|
357 RPointerArray<CCalEntry> entries; |
|
358 CleanupStack::PushL( |
|
359 TCleanupItem( |
|
360 CalEntryPointerArrayCleanup, |
|
361 &entries ) ); |
|
362 |
|
363 // Fetches parent entry. We need to construct entry with |
|
364 // correct time. |
|
365 CCalEntry &entry = aInstance.Entry(); |
|
366 CCalEntry* instanceEntry = ESMRHelper::CopyEntryL( |
|
367 entry, |
|
368 entry.MethodL(), |
|
369 ESMRHelper::ECopyFull ); |
|
370 |
|
371 entries.Append(instanceEntry); |
|
372 |
|
373 // Setting start and end time for child entry |
|
374 CheckRepeatUntilValidityL( |
|
375 *instanceEntry, |
|
376 aInstance.StartTimeL() ); |
|
377 |
|
378 SetInstanceStartAndEndL( |
|
379 *instanceEntry, |
|
380 entry, |
|
381 aInstance.StartTimeL() ); |
|
382 |
|
383 // Filling child with correct data |
|
384 // This can be replaced withCCalenInterimUtils2::PopulateChildFromParentL |
|
385 // after its memory leak has been fixed. |
|
386 ESMRHelper::PopulateChildFromParentL( |
|
387 *instanceEntry, |
|
388 entry ); |
|
389 |
|
390 ProcessL( &entries ); |
|
391 |
|
392 if ( !iESMREntry ) |
|
393 { |
|
394 User::Leave( KErrArgument ); |
|
395 } |
|
396 |
|
397 // Mark only this entry to be affected. |
|
398 iESMREntry->SetModifyingRuleL( |
|
399 MESMRMeetingRequestEntry::EESMRThisOnly ); |
|
400 |
|
401 CleanupStack::PopAndDestroy( &entries ); |
|
402 |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // CESMREntryProcessor::SwitchToForwardL |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 EXPORT_C void CESMREntryProcessor::SwitchToForwardL() |
|
410 { |
|
411 FUNC_LOG; |
|
412 |
|
413 if ( !iESMREntry ) |
|
414 { |
|
415 // No entries has been processed yet. |
|
416 User::Leave( KErrNotReady ); |
|
417 } |
|
418 |
|
419 iESMREntry->SwitchToForwardL(); |
|
420 |
|
421 // Rest of the scenario data remains as it is |
|
422 iScenData.iViewMode = EESMRForwardMR; |
|
423 |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // CESMREntryProcessor::SwitchToViewL |
|
428 // --------------------------------------------------------------------------- |
|
429 // |
|
430 EXPORT_C void CESMREntryProcessor::SwitchToEditL() |
|
431 { |
|
432 FUNC_LOG; |
|
433 |
|
434 if ( !iESMREntry ) |
|
435 { |
|
436 // No entries has been processed yet. |
|
437 User::Leave( KErrNotReady ); |
|
438 } |
|
439 |
|
440 iESMREntry->SwitchToOrginalL(); |
|
441 |
|
442 // Rest of the scenario data remains as it is |
|
443 iScenData.iViewMode = EESMREditMR; |
|
444 |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------------------------- |
|
448 // CESMREntryProcessor::SwitchToViewL |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 EXPORT_C void CESMREntryProcessor::SwitchToViewL() |
|
452 { |
|
453 FUNC_LOG; |
|
454 |
|
455 if ( !iESMREntry ) |
|
456 { |
|
457 // No entries has been processed yet. |
|
458 User::Leave( KErrNotReady ); |
|
459 } |
|
460 |
|
461 iESMREntry->SwitchToOrginalL(); |
|
462 |
|
463 // Rest of the scenario data remains as it is |
|
464 iScenData.iViewMode = EESMRViewMR; |
|
465 |
|
466 } |
|
467 |
|
468 // --------------------------------------------------------------------------- |
|
469 // CESMREntryProcessor::SwitchToTrackL |
|
470 // --------------------------------------------------------------------------- |
|
471 // |
|
472 EXPORT_C void CESMREntryProcessor::SwitchToTrackL() |
|
473 { |
|
474 FUNC_LOG; |
|
475 |
|
476 if ( !iESMREntry ) |
|
477 { |
|
478 // No entries has been processed yet. |
|
479 User::Leave( KErrNotReady ); |
|
480 } |
|
481 |
|
482 iESMREntry->SwitchToOrginalL(); |
|
483 |
|
484 // Rest of the scenario data remains as it is |
|
485 iScenData.iViewMode = EESMRTrackingViewMR; |
|
486 iScenData.iRole = EESMRRoleOrganizer; |
|
487 iScenData.iEntryType = EESMREventTypeAppt; |
|
488 |
|
489 |
|
490 } |
|
491 |
|
492 // --------------------------------------------------------------------------- |
|
493 // CESMREntryProcessor::ESMREntryL |
|
494 // --------------------------------------------------------------------------- |
|
495 // |
|
496 EXPORT_C MESMRMeetingRequestEntry& CESMREntryProcessor::ESMREntryL() |
|
497 { |
|
498 FUNC_LOG; |
|
499 CreateESMREntryL(); |
|
500 return *iESMREntry; |
|
501 } |
|
502 |
|
503 // --------------------------------------------------------------------------- |
|
504 // CESMREntryProcessor::ResetL |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 EXPORT_C void CESMREntryProcessor::ResetL() |
|
508 { |
|
509 FUNC_LOG; |
|
510 |
|
511 iScenData.iRole = EESMRRoleUndef; |
|
512 iScenData.iViewMode = EESMRViewUndef; |
|
513 iScenData.iCallingApp = EESMRAppUndef; |
|
514 |
|
515 delete iESMREntry; |
|
516 iESMREntry = NULL; |
|
517 |
|
518 } |
|
519 |
|
520 // --------------------------------------------------------------------------- |
|
521 // CESMREntryProcessor::ProcessOutputParametersL |
|
522 // --------------------------------------------------------------------------- |
|
523 // |
|
524 EXPORT_C void CESMREntryProcessor::ProcessOutputParametersL( |
|
525 MAgnEntryUi::TAgnEntryUiOutParams& aOutParams, |
|
526 TESMRCommand aCommand ) |
|
527 { |
|
528 FUNC_LOG; |
|
529 |
|
530 __ASSERT_DEBUG( iESMREntry, Panic(EESMRProcessorEntriesNotProcessed) ); |
|
531 |
|
532 if ( !iParams || |
|
533 EESMRForwardMR == iScenData.iViewMode || |
|
534 EESMRViewUndef == iScenData.iViewMode ) |
|
535 { |
|
536 // No input parameters supplied --> Output parameters cannot be set |
|
537 return; |
|
538 } |
|
539 |
|
540 TBool handlingInstanceOnly( |
|
541 iESMREntry->IsRecurrentEventL() && |
|
542 MESMRCalEntry::EESMRThisOnly == iESMREntry->RecurrenceModRule() ); |
|
543 |
|
544 switch ( aCommand ) |
|
545 { |
|
546 case EESMRCmdSendMR: |
|
547 case EESMRCmdSendMRUpdate: |
|
548 case EESMRCmdSaveMR: |
|
549 case EESMRCmdAcceptMR: |
|
550 case EESMRCmdTentativeMR: |
|
551 { |
|
552 aOutParams.iAction = MAgnEntryUi::EMeetingSaved; |
|
553 if ( handlingInstanceOnly ) |
|
554 { |
|
555 aOutParams.iAction = MAgnEntryUi::EInstanceRescheduled; |
|
556 } |
|
557 } |
|
558 break; |
|
559 |
|
560 case EESMRCmdDeclineMR: |
|
561 case EESMRCmdDeleteMR: |
|
562 { |
|
563 aOutParams.iAction = MAgnEntryUi::EMeetingDeleted; |
|
564 if ( handlingInstanceOnly ) |
|
565 { |
|
566 aOutParams.iAction = MAgnEntryUi::EInstanceDeleted; |
|
567 } |
|
568 } |
|
569 break; |
|
570 |
|
571 default: |
|
572 { |
|
573 aOutParams.iAction = MAgnEntryUi::ENoAction; |
|
574 } |
|
575 break; |
|
576 } |
|
577 |
|
578 if ( handlingInstanceOnly ) |
|
579 { |
|
580 aOutParams.iNewInstanceDate = |
|
581 iESMREntry->Entry().StartTimeL(); |
|
582 } |
|
583 else if ( MAgnEntryUi::ENoAction != aOutParams.iAction ) |
|
584 { |
|
585 // Copy entry details to input entry |
|
586 CCalEntry& baseEntry = *((*iMREntries)[KFirstEntryIndex]); |
|
587 baseEntry.CopyFromL( iESMREntry->Entry() ); |
|
588 |
|
589 TCalTime instanceTime = iESMREntry->Entry().StartTimeL(); |
|
590 |
|
591 if ( MESMRCalEntry::EESMRAllInSeries == iESMREntry->RecurrenceModRule() ) |
|
592 { |
|
593 // For recurrent event there might be exceptions |
|
594 // and therefore the first possible start time |
|
595 // is set to putput params |
|
596 TCalTime end; |
|
597 CESMRRecurrenceInfoHandler* recurrenceHandler = |
|
598 CESMRRecurrenceInfoHandler::NewLC( iESMREntry->Entry() ); |
|
599 |
|
600 recurrenceHandler->GetFirstInstanceTimeL( |
|
601 instanceTime, |
|
602 end ); |
|
603 |
|
604 CleanupStack::PopAndDestroy( recurrenceHandler ); |
|
605 recurrenceHandler = NULL; |
|
606 aOutParams.iNewInstanceDate = instanceTime; |
|
607 } |
|
608 else |
|
609 { |
|
610 aOutParams.iNewInstanceDate.SetTimeLocalL( |
|
611 iESMREntry->Entry().StartTimeL().TimeLocalL() ); |
|
612 } |
|
613 } |
|
614 else |
|
615 { |
|
616 aOutParams.iNewInstanceDate.SetTimeLocalL( Time::NullTTime() ); |
|
617 } |
|
618 |
|
619 } |
|
620 |
|
621 // --------------------------------------------------------------------------- |
|
622 // CESMREntryProcessor::SetPhoneOwnerL |
|
623 // --------------------------------------------------------------------------- |
|
624 // |
|
625 void CESMREntryProcessor::SetPhoneOwnerL() |
|
626 { |
|
627 FUNC_LOG; |
|
628 |
|
629 TInt count( iMREntries->Count() ); |
|
630 for ( TInt i( 0 ); i < count; ++i ) |
|
631 { |
|
632 // Set phone owner for all entries |
|
633 CCalEntry& entry = *( (*iMREntries)[i] ); |
|
634 |
|
635 TESMRInputParams* inputParams = NULL; |
|
636 if ( iParams ) |
|
637 { |
|
638 inputParams = (TESMRInputParams*)(iParams->iSpare); |
|
639 } |
|
640 |
|
641 TInt err(KErrNone); |
|
642 if ( inputParams && |
|
643 inputParams->iMailClient && |
|
644 inputParams->iMailMessage ) |
|
645 { |
|
646 err = iMbUtils->SetPhoneOwnerL( |
|
647 entry, |
|
648 *(inputParams->iMailClient), |
|
649 *(inputParams->iMailMessage) ); |
|
650 } |
|
651 else if ( iParams ) |
|
652 { |
|
653 err = iMbUtils->SetPhoneOwnerL( |
|
654 entry, |
|
655 iParams->iMailBoxId ); |
|
656 } |
|
657 else |
|
658 { |
|
659 err = iMbUtils->SetPhoneOwnerL( entry ); |
|
660 } |
|
661 |
|
662 if ( KErrNone != err ) |
|
663 { |
|
664 User::Leave( KErrArgument ); |
|
665 } |
|
666 } |
|
667 |
|
668 // set iOwnerRole, use entry at index zero: |
|
669 CCalEntry& baseEntry = *( (*iMREntries)[KFirstEntryIndex] ); |
|
670 if ( iMRMailboxUtils.IsOrganizerL( baseEntry ) ) |
|
671 { |
|
672 iScenData.iRole = EESMRRoleOrganizer; |
|
673 } |
|
674 else |
|
675 { |
|
676 // We are not organizer. Let's see if we are in attendee list |
|
677 // or not. |
|
678 CCalAttendee* thisAttendee = |
|
679 iMRMailboxUtils.ThisAttendeeL( baseEntry ); |
|
680 if ( thisAttendee ) |
|
681 { |
|
682 switch ( thisAttendee->RoleL() ) |
|
683 { |
|
684 case CCalAttendee::EOptParticipant: |
|
685 { |
|
686 iScenData.iRole = EESMRRoleOptionalAttendee; |
|
687 break; |
|
688 } |
|
689 case CCalAttendee::ENonParticipant: |
|
690 { |
|
691 iScenData.iRole = EESMRRoleNonParticipant; |
|
692 break; |
|
693 } |
|
694 case CCalAttendee::EReqParticipant: // fall through |
|
695 case CCalAttendee::EChair: // fall through |
|
696 default: |
|
697 { // Note: chair MUST NOT be interpreted as organizer |
|
698 // Req.participant is not correct either but has less |
|
699 // side effects. |
|
700 iScenData.iRole = EESMRRoleRequiredAttendee; |
|
701 break; |
|
702 } |
|
703 } |
|
704 } |
|
705 else |
|
706 { |
|
707 // Phone owner cannot be set --> Leave |
|
708 User::Leave( KErrCorrupt ); |
|
709 } |
|
710 } |
|
711 |
|
712 } |
|
713 |
|
714 // --------------------------------------------------------------------------- |
|
715 // CESMREntryProcessor::CheckViewModeL |
|
716 // --------------------------------------------------------------------------- |
|
717 // |
|
718 void CESMREntryProcessor::CheckViewModeL() |
|
719 { |
|
720 FUNC_LOG; |
|
721 |
|
722 // View mode cannot be checked |
|
723 __ASSERT_DEBUG( |
|
724 iESMREntry, |
|
725 Panic(EESMRProcessorCannotCheckViewMode) ); |
|
726 |
|
727 TInt32 callingAppUid = iParams->iCallingApp.iUid; |
|
728 switch ( callingAppUid ) |
|
729 { |
|
730 case KUidCalendarApplication: |
|
731 { |
|
732 iScenData.iCallingApp = EESMRAppCalendar; |
|
733 iScenData.iViewMode = EESMRViewMR; |
|
734 if ( MAgnEntryUi::EViewEntry == iParams->iEditorMode ) |
|
735 { |
|
736 if ( iESMREntry->IsAllDayEventL() ) |
|
737 { |
|
738 iScenData.iViewMode = EESMRViewAllDayMR; |
|
739 } |
|
740 } |
|
741 else |
|
742 { |
|
743 iScenData.iViewMode = EESMREditMR; |
|
744 } |
|
745 break; |
|
746 } |
|
747 case KUidMceMailApplication: |
|
748 case KUidEsMailApplication: |
|
749 case KUidBVAApplication: |
|
750 { |
|
751 iScenData.iCallingApp = EESMRAppESEmail; |
|
752 iScenData.iViewMode = EESMRViewMR; |
|
753 |
|
754 if ( iESMREntry->IsAllDayEventL() ) |
|
755 { |
|
756 iScenData.iViewMode = EESMRViewAllDayMR; |
|
757 } |
|
758 break; |
|
759 } |
|
760 default: |
|
761 { |
|
762 //error situation, should never come here |
|
763 // Setting data to undef --> will leave later on. |
|
764 iScenData.iViewMode = EESMRViewUndef; |
|
765 break; |
|
766 } |
|
767 } |
|
768 |
|
769 } |
|
770 |
|
771 // --------------------------------------------------------------------------- |
|
772 // CESMREntryProcessor::SetPhoneOwnerL |
|
773 // --------------------------------------------------------------------------- |
|
774 // |
|
775 TBool CESMREntryProcessor::IsDataOk() const |
|
776 { |
|
777 FUNC_LOG; |
|
778 |
|
779 #ifdef _DEBUG |
|
780 LogScenatioData( iScenData ); |
|
781 #endif |
|
782 |
|
783 TBool retVal(ETrue); |
|
784 |
|
785 // Check that all values has been set and there is no |
|
786 // undefined values. Policies cannot be resolved, if |
|
787 // scenario data is undefined. |
|
788 if ( EESMRRoleUndef == iScenData.iRole || |
|
789 EESMRViewUndef == iScenData.iViewMode || |
|
790 EESMRAppUndef == iScenData.iCallingApp ) |
|
791 { |
|
792 retVal = EFalse; |
|
793 } |
|
794 |
|
795 |
|
796 |
|
797 return retVal; |
|
798 } |
|
799 |
|
800 // --------------------------------------------------------------------------- |
|
801 // CESMREntryProcessor::CreateESMREntryL |
|
802 // --------------------------------------------------------------------------- |
|
803 // |
|
804 void CESMREntryProcessor::CreateESMREntryL() |
|
805 { |
|
806 FUNC_LOG; |
|
807 |
|
808 __ASSERT_DEBUG( iMREntries, Panic(EESMRProcessorEntriesNotProcessed) ); |
|
809 |
|
810 if ( !iESMREntry ) |
|
811 { |
|
812 // ES MR Entry is created |
|
813 CCalEntry& base = *((*iMREntries)[KFirstEntryIndex]); |
|
814 HBufC* description = NULL; |
|
815 TRAPD( err, description = base.DescriptionL().AllocL() ); |
|
816 CleanupStack::PushL( description ); |
|
817 if ( KErrNone != err ) |
|
818 { |
|
819 User::Leave( KErrCorrupt ); |
|
820 } |
|
821 CleanupStack::PopAndDestroy( description ); |
|
822 description = NULL; |
|
823 |
|
824 CCalEntry* entry = |
|
825 ESMRHelper::CopyEntryLC( |
|
826 base, |
|
827 base.MethodL(), |
|
828 ESMRHelper::ECopyFull ); |
|
829 |
|
830 CESMRConflictChecker* conflictChecker = |
|
831 CESMRConflictChecker::NewL(iDbMgr); |
|
832 CleanupStack::PushL( conflictChecker ); |
|
833 |
|
834 RPointerArray<CCalEntry> conflicts; |
|
835 CleanupStack::PushL( |
|
836 TCleanupItem( |
|
837 CalEntryPointerArrayCleanup, |
|
838 &conflicts ) ); |
|
839 |
|
840 conflictChecker->FindConflictsL( *entry, conflicts ); |
|
841 TBool conflictsExists( conflicts.Count() ); |
|
842 |
|
843 if ( iParams && |
|
844 KUidCalendarApplication == iParams->iCallingApp.iUid ) |
|
845 { |
|
846 // Setting start and end time for child entry |
|
847 CheckRepeatUntilValidityL( |
|
848 *entry, |
|
849 iParams->iInstanceDate ); |
|
850 |
|
851 SetInstanceStartAndEndL( |
|
852 *entry, |
|
853 base, |
|
854 iParams->iInstanceDate ); |
|
855 } |
|
856 |
|
857 TESMRInputParams* inputParams = NULL; |
|
858 if ( iParams ) |
|
859 { |
|
860 inputParams = (TESMRInputParams*)(iParams->iSpare); |
|
861 } |
|
862 |
|
863 iESMREntry = |
|
864 CESMRMeetingRequestEntry::NewL( |
|
865 *entry, |
|
866 iMRMailboxUtils, |
|
867 iDbMgr, |
|
868 conflictsExists, |
|
869 inputParams ); |
|
870 |
|
871 CleanupStack::PopAndDestroy(); // conflicts |
|
872 CleanupStack::PopAndDestroy( conflictChecker ); |
|
873 CleanupStack::PopAndDestroy( entry ); |
|
874 |
|
875 SetPhoneOwnerToOwnEntryL(); |
|
876 } |
|
877 |
|
878 } |
|
879 |
|
880 // --------------------------------------------------------------------------- |
|
881 // CESMREntryProcessor::CheckOrganizerL |
|
882 // --------------------------------------------------------------------------- |
|
883 // |
|
884 void CESMREntryProcessor::CheckOrganizerL() |
|
885 { |
|
886 FUNC_LOG; |
|
887 |
|
888 __ASSERT_DEBUG( iMREntries, Panic(EESMRProcessorEntriesNotProcessed) ); |
|
889 |
|
890 if ( EESMRRoleOrganizer == iScenData.iRole ) |
|
891 { |
|
892 CCalEntry& entry = *((*iMREntries)[KFirstEntryIndex]); |
|
893 |
|
894 CCalUser *phoneOwner = entry.PhoneOwnerL(); |
|
895 |
|
896 if ( !phoneOwner ) |
|
897 { |
|
898 User::Leave( KErrCorrupt ); |
|
899 } |
|
900 |
|
901 CCalUser* organizer = ESMRHelper::CopyUserLC( *phoneOwner ); |
|
902 |
|
903 // Ownership is transferred |
|
904 entry.SetOrganizerL( organizer ); |
|
905 CleanupStack::Pop( organizer ); |
|
906 } |
|
907 |
|
908 } |
|
909 |
|
910 // --------------------------------------------------------------------------- |
|
911 // CESMREntryProcessor::SetPhoneOwnerToOwnEntryL |
|
912 // --------------------------------------------------------------------------- |
|
913 // |
|
914 void CESMREntryProcessor::SetPhoneOwnerToOwnEntryL() |
|
915 { |
|
916 FUNC_LOG; |
|
917 |
|
918 // Phone owner cannot be checked |
|
919 __ASSERT_DEBUG( |
|
920 iESMREntry, |
|
921 Panic(EESMRProcessorEntriesNotProcessed) ); |
|
922 |
|
923 TESMRInputParams* inputParams = NULL; |
|
924 if ( iParams ) |
|
925 { |
|
926 inputParams = (TESMRInputParams*)(iParams->iSpare); |
|
927 } |
|
928 |
|
929 TInt err(KErrNone); |
|
930 if ( inputParams && |
|
931 inputParams->iMailClient && |
|
932 inputParams->iMailMessage ) |
|
933 { |
|
934 err = iMbUtils->SetPhoneOwnerL( |
|
935 iESMREntry->Entry(), |
|
936 *(inputParams->iMailClient), |
|
937 *(inputParams->iMailMessage) ); |
|
938 } |
|
939 else if ( iParams ) |
|
940 { |
|
941 err = iMbUtils->SetPhoneOwnerL( |
|
942 iESMREntry->Entry(), |
|
943 iParams->iMailBoxId ); |
|
944 } |
|
945 else |
|
946 { |
|
947 err = iMbUtils->SetPhoneOwnerL( iESMREntry->Entry() ); |
|
948 } |
|
949 |
|
950 User::LeaveIfError( err ); |
|
951 |
|
952 } |
|
953 |
|
954 // EOF |
|
955 |
|