|
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 MR Entry implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 //<cmail> |
|
21 #include "emailtrace.h" |
|
22 #include "cesmralarminfohandler.h" |
|
23 #include "cesmrrecurrenceinfohandler.h" |
|
24 //</cmail> |
|
25 #include <centralrepository.h> |
|
26 #include <calalarm.h> |
|
27 |
|
28 #include "cesmrmeetingrequestentry.h" |
|
29 #include "cesmrfsmailboxutils.h" |
|
30 #include "cesmrcaldbmgr.h" |
|
31 #include "esmrhelper.h" |
|
32 #include "esmrentryhelper.h" |
|
33 #include "cesmrconflictchecker.h" |
|
34 #include "cesmrcaluserutil.h" |
|
35 #include "esmrconfig.hrh" |
|
36 |
|
37 #include <esmralarminfo.rsg> |
|
38 #include <calentry.h> |
|
39 #include <calinstance.h> |
|
40 #include <calinstanceview.h> |
|
41 #include <caluser.h> |
|
42 #include <CalenInterimUtils2.h> |
|
43 #include <cmrmailboxutils.h> |
|
44 #include <calrrule.h> |
|
45 //<cmail> |
|
46 #include "mmrinfoobject.h" |
|
47 #include "mmrattendee.h" |
|
48 //</cmail> |
|
49 #include <CalendarInternalCRKeys.h> |
|
50 #include <data_caging_path_literals.hrh> |
|
51 #include <coemain.h> |
|
52 #include <calentryview.h> |
|
53 #include <ct/rcpointerarray.h> |
|
54 |
|
55 /// Unnamed namespace for local definitions |
|
56 namespace { |
|
57 |
|
58 // Alarm resource file location |
|
59 _LIT( KAlarmInfoResource, "esmralarminfo.rsc" ); |
|
60 |
|
61 // Definition for first index |
|
62 const TInt KFirstIndex = 0; |
|
63 |
|
64 // Definition for 0 |
|
65 const TInt KZero = 0; |
|
66 |
|
67 // Definition for 1 |
|
68 const TInt KOne = 1; |
|
69 |
|
70 // Definition for number of hours within day |
|
71 const TInt KHoursInDay = 24; |
|
72 |
|
73 // Definition for default alarm time for meeting |
|
74 const TInt KDefaultMeetingAlarmMinutes( 15 ); |
|
75 |
|
76 _LIT( KReplaceLineFeedChar, "\n" ); |
|
77 _LIT( KLineFeed, "\x2029"); |
|
78 |
|
79 /** |
|
80 * Finds matching calendar instance from calendar db. Ownership is |
|
81 * transferred, If instance cannot be found, NULL is returned. |
|
82 * |
|
83 * @param aCalDb Reference to cal db manager. |
|
84 * @param aEntry Reference to calendar entry |
|
85 * @return Pointer to calendar entry instance. |
|
86 */ |
|
87 CCalInstance* FindInstanceL( |
|
88 MESMRCalDbMgr& aCalDb, |
|
89 CCalEntry& aEntry ) |
|
90 { |
|
91 CCalInstance* instance = NULL; |
|
92 RCPointerArray<CCalInstance> calInstances; |
|
93 CleanupClosePushL( calInstances ); |
|
94 |
|
95 CCalInstanceView* instanceView = |
|
96 aCalDb.NormalDbInstanceView(); |
|
97 |
|
98 CalCommon::TCalViewFilter instanceFilter = |
|
99 CalCommon::EIncludeAppts | |
|
100 CalCommon::EIncludeEvents; |
|
101 |
|
102 // Removing one seconds from start time and adding one second to stop |
|
103 // time. Otherwise wanted entry is not included into results. |
|
104 TCalTime startTime; |
|
105 startTime.SetTimeLocalL( |
|
106 aEntry.StartTimeL().TimeLocalL() - TTimeIntervalSeconds(KOne) ); |
|
107 TCalTime endTime; |
|
108 endTime.SetTimeLocalL( |
|
109 aEntry.EndTimeL().TimeLocalL() + TTimeIntervalSeconds(KOne) ); |
|
110 |
|
111 TDateTime start = startTime.TimeLocalL().DateTime(); |
|
112 TDateTime end = endTime.TimeLocalL().DateTime(); |
|
113 |
|
114 CalCommon::TCalTimeRange timeRange( |
|
115 startTime, |
|
116 endTime ); |
|
117 |
|
118 instanceView->FindInstanceL( |
|
119 calInstances, |
|
120 instanceFilter, |
|
121 timeRange); |
|
122 |
|
123 TInt instanceCount( calInstances.Count() ); |
|
124 for (TInt i = 0; (i < instanceCount && !instance); ++i) |
|
125 { |
|
126 CCalEntry& entry = calInstances[i]->Entry(); |
|
127 |
|
128 // Finding the entry we are intrested for |
|
129 if ( !entry.UidL().Compare( aEntry.UidL() ) ) |
|
130 { |
|
131 instance = calInstances[i]; |
|
132 calInstances.Remove( i ); |
|
133 } |
|
134 } |
|
135 CleanupStack::PopAndDestroy(); // arrayCleanup |
|
136 return instance; |
|
137 } |
|
138 |
|
139 #ifdef _DEBUG |
|
140 |
|
141 // Definition for panic text |
|
142 _LIT( KESMREntryPanicTxt, "ESMRMeetingRequestEntry" ); |
|
143 |
|
144 /** |
|
145 * ES MR Entry panic codes |
|
146 */ |
|
147 enum TESMRMeetingRequestEntry |
|
148 { |
|
149 EESMREntryNotExist = 1, // Entry does not exist |
|
150 EESMRInvalidRole, // Phone owner has invalid role |
|
151 EESMRNoInfoObjectAttendeeFound, |
|
152 EESMRPhoneOwnerNotSet, |
|
153 EESMRRecurrenceError, |
|
154 EESMRInvalidReplyType, |
|
155 EESMRInvalidInvalidAttendeeStatus, |
|
156 EESMRParentNotFound |
|
157 }; |
|
158 |
|
159 /** |
|
160 * Raises panic. |
|
161 * @param aPanic Panic code |
|
162 */ |
|
163 void Panic(TESMRMeetingRequestEntry aPanic) |
|
164 { |
|
165 User::Panic( KESMREntryPanicTxt, aPanic); |
|
166 } |
|
167 |
|
168 #endif // _DEBUG |
|
169 |
|
170 } // namespace |
|
171 |
|
172 // ======== MEMBER FUNCTIONS ======== |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CESMRMeetingRequestEntry::CESMRMeetingRequestEntry |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 inline CESMRMeetingRequestEntry::CESMRMeetingRequestEntry( |
|
179 CMRMailboxUtils& aMRMailboxUtils, |
|
180 MESMRCalDbMgr& aCalDb, |
|
181 TBool aConflictsExists, |
|
182 TESMRInputParams* aESMRInputParams ) |
|
183 : iMRMailboxUtils( aMRMailboxUtils ), |
|
184 iConflictsExists( aConflictsExists), |
|
185 iCalDb( aCalDb ), |
|
186 iESMRInputParams( aESMRInputParams ) |
|
187 { |
|
188 FUNC_LOG; |
|
189 // Not yet implementation |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 CESMRMeetingRequestEntry::~CESMRMeetingRequestEntry() |
|
197 { |
|
198 FUNC_LOG; |
|
199 delete iEntry; |
|
200 delete iForwardEntry; |
|
201 delete iOrginalEntry; |
|
202 delete iParameterEntry; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CESMRMeetingRequestEntry::NewL |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 CESMRMeetingRequestEntry* CESMRMeetingRequestEntry::NewL( |
|
210 const CCalEntry& aEntry, |
|
211 CMRMailboxUtils& aMRMailboxUtils, |
|
212 MESMRCalDbMgr& aCalDb, |
|
213 TBool aConflictsExists, |
|
214 TESMRInputParams* aESMRInputParams ) |
|
215 { |
|
216 FUNC_LOG; |
|
217 |
|
218 CESMRMeetingRequestEntry* self = |
|
219 new (ELeave) CESMRMeetingRequestEntry( |
|
220 aMRMailboxUtils, |
|
221 aCalDb, |
|
222 aConflictsExists, |
|
223 aESMRInputParams ); |
|
224 |
|
225 CleanupStack::PushL( self ); |
|
226 self->ConstructL( aEntry ); |
|
227 CleanupStack::Pop( self ); |
|
228 |
|
229 return self; |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // CESMRMeetingRequestEntry::ConstructL |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 void CESMRMeetingRequestEntry::ConstructL( |
|
237 const CCalEntry& aEntry ) |
|
238 { |
|
239 FUNC_LOG; |
|
240 |
|
241 iParameterEntry = ESMRHelper::CopyEntryL( |
|
242 aEntry, |
|
243 aEntry.MethodL(), |
|
244 ESMRHelper::ECopyFull ); |
|
245 |
|
246 iEntry = ESMRHelper::CopyEntryL( |
|
247 aEntry, |
|
248 aEntry.MethodL(), |
|
249 ESMRHelper::ECopyFull ); |
|
250 |
|
251 if ( !IsStoredL() && !IsOpenedFromMail() ) |
|
252 { |
|
253 // by default when creating a meeting the priority value is normal |
|
254 SetPriorityL( EFSCalenMRPriorityNormal ); |
|
255 } |
|
256 |
|
257 iOrginalEntry = ESMRHelper::CopyEntryL( |
|
258 aEntry, |
|
259 aEntry.MethodL(), |
|
260 ESMRHelper::ECopyFull ); |
|
261 |
|
262 if ( EESMRRoleOrganizer == RoleL() && IsStoredL() ) |
|
263 { |
|
264 // Increase sequence number |
|
265 TInt seqNo( iEntry->SequenceNumberL() + 1); |
|
266 iEntry->SetSequenceNumberL( seqNo ); |
|
267 iOrginalEntry->SetSequenceNumberL( seqNo ); |
|
268 } |
|
269 |
|
270 |
|
271 CCalEntry::TMethod method( iEntry->MethodL() ); |
|
272 |
|
273 if ( CCalEntry::EMethodNone == method ) |
|
274 { |
|
275 iEntry->SetMethodL( CCalEntry::EMethodRequest ); |
|
276 iOrginalEntry->SetMethodL( CCalEntry::EMethodRequest ); |
|
277 } |
|
278 |
|
279 HBufC* newDescription = ReplaceCharactersFromBufferLC( |
|
280 iEntry->DescriptionL(), |
|
281 KReplaceLineFeedChar(), |
|
282 KLineFeed() ); |
|
283 iEntry->SetDescriptionL( *newDescription ); |
|
284 CleanupStack::PopAndDestroy( newDescription ); |
|
285 |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // CESMRMeetingRequestEntry::ReplaceCharactersFromBufferL |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 HBufC* CESMRMeetingRequestEntry::ReplaceCharactersFromBufferLC( const TDesC& aTarget, |
|
293 const TDesC& aFindString, |
|
294 const TDesC& aReplacement ) |
|
295 { |
|
296 FUNC_LOG; |
|
297 HBufC* newBuffer = aTarget.AllocLC(); |
|
298 TPtr16 ptr = newBuffer->Des(); |
|
299 |
|
300 // find next occurance: |
|
301 TInt offset = ptr.Find(aFindString); |
|
302 while ( offset != KErrNotFound ) |
|
303 { |
|
304 // replace the data: |
|
305 ptr.Replace( offset, aFindString.Length(), aReplacement); |
|
306 |
|
307 // find next occurance: |
|
308 offset = ptr.Find(aFindString); |
|
309 } |
|
310 |
|
311 return newBuffer; |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CESMRMeetingRequestEntry::Type |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 MESMRCalEntry::TESMRCalEntryType CESMRMeetingRequestEntry::Type() const |
|
319 { |
|
320 FUNC_LOG; |
|
321 // This is meeting request |
|
322 return MESMRCalEntry::EESMRCalEntryMeetingRequest; |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // CESMRMeetingRequestEntry::MESMRCalEntryRef |
|
327 // --------------------------------------------------------------------------- |
|
328 // |
|
329 MESMRCalEntry& CESMRMeetingRequestEntry::MESMRCalEntryRef() |
|
330 { |
|
331 FUNC_LOG; |
|
332 return *this; |
|
333 } |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // CESMRMeetingRequestEntry::MESMRCalEntryRef |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 const MESMRCalEntry& CESMRMeetingRequestEntry::MESMRCalEntryRef() const |
|
340 { |
|
341 FUNC_LOG; |
|
342 return *this; |
|
343 } |
|
344 // --------------------------------------------------------------------------- |
|
345 // CESMRMeetingRequestEntry::Entry |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 CCalEntry& CESMRMeetingRequestEntry::Entry() |
|
349 { |
|
350 FUNC_LOG; |
|
351 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
352 |
|
353 if ( iForwardEntry ) |
|
354 { |
|
355 return *iForwardEntry; |
|
356 } |
|
357 |
|
358 return *iEntry; |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------------------------- |
|
362 // CESMRMeetingRequestEntry::Entry |
|
363 // --------------------------------------------------------------------------- |
|
364 // |
|
365 const CCalEntry& CESMRMeetingRequestEntry::Entry() const |
|
366 { |
|
367 FUNC_LOG; |
|
368 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
369 if ( iForwardEntry ) |
|
370 { |
|
371 return *iForwardEntry; |
|
372 } |
|
373 return *iEntry; |
|
374 } |
|
375 |
|
376 // --------------------------------------------------------------------------- |
|
377 // CESMRMeetingRequestEntry::InstanceL |
|
378 // --------------------------------------------------------------------------- |
|
379 // |
|
380 CCalInstance* CESMRMeetingRequestEntry::InstanceL() const |
|
381 { |
|
382 FUNC_LOG; |
|
383 |
|
384 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
385 __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) ); |
|
386 |
|
387 CCalInstance* instance = NULL; |
|
388 |
|
389 instance = FindInstanceL( iCalDb, *iEntry ); |
|
390 if ( !instance ) |
|
391 { |
|
392 // Instance not found by using the edited entry |
|
393 // Trying with orginal. |
|
394 instance = FindInstanceL( iCalDb, *iOrginalEntry ); |
|
395 } |
|
396 |
|
397 if ( !instance ) |
|
398 { |
|
399 // Instance not found by using edited or orginal entry. |
|
400 // --> Leave |
|
401 |
|
402 |
|
403 User::Leave( KErrNotFound ); |
|
404 } |
|
405 |
|
406 |
|
407 return instance; |
|
408 } |
|
409 |
|
410 // --------------------------------------------------------------------------- |
|
411 // CESMRMeetingRequestEntry::CanSetRecurrenceL |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 TBool CESMRMeetingRequestEntry::CanSetRecurrenceL() const |
|
415 { |
|
416 FUNC_LOG; |
|
417 |
|
418 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
419 |
|
420 TBool canSetRecurrence( ETrue ); |
|
421 |
|
422 if ( iEntry->EntryTypeL() == CCalEntry::EAppt && |
|
423 ESMREntryHelper::IsRepeatingMeetingL(*iEntry) && |
|
424 (!ESMREntryHelper::IsModifyingEntryL(*iEntry) && |
|
425 MESMRCalEntry::EESMRThisOnly == iRecurrenceModRule )) |
|
426 { |
|
427 canSetRecurrence = EFalse; |
|
428 } |
|
429 |
|
430 |
|
431 return canSetRecurrence; |
|
432 } |
|
433 |
|
434 // --------------------------------------------------------------------------- |
|
435 // CESMRMeetingRequestEntry::IsRecurrentEventL |
|
436 // --------------------------------------------------------------------------- |
|
437 // |
|
438 TBool CESMRMeetingRequestEntry::IsRecurrentEventL() const |
|
439 { |
|
440 FUNC_LOG; |
|
441 |
|
442 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
443 |
|
444 TBool recurrenceEvent( EFalse ); |
|
445 if ( IsStoredL() ) |
|
446 { |
|
447 // Entry is stored in calendar db |
|
448 // Lets look recurrence using instance |
|
449 |
|
450 // Ownership is transferred |
|
451 CCalInstance* instance = NULL; |
|
452 TRAPD(err, instance = InstanceL() ); |
|
453 if ( KErrNotFound != err ) |
|
454 { |
|
455 User::LeaveIfError( err ); |
|
456 } |
|
457 |
|
458 if ( instance ) |
|
459 { |
|
460 CleanupStack::PushL( instance ); |
|
461 |
|
462 CCalEntry& instanceParentEntry = instance->Entry(); |
|
463 |
|
464 if ( ESMREntryHelper::IsRepeatingMeetingL( instanceParentEntry ) ) |
|
465 { |
|
466 recurrenceEvent = ETrue; |
|
467 } |
|
468 CleanupStack::PopAndDestroy( instance ); |
|
469 } |
|
470 else if ( ESMREntryHelper::IsRepeatingMeetingL( *iEntry ) ) |
|
471 { |
|
472 recurrenceEvent = ETrue; |
|
473 } |
|
474 } |
|
475 else |
|
476 { |
|
477 // Entry is not stored in calendar db |
|
478 if ( ESMREntryHelper::IsRepeatingMeetingL( *iEntry ) ) |
|
479 { |
|
480 // This is repeating meeting |
|
481 recurrenceEvent = ETrue; |
|
482 } |
|
483 } |
|
484 |
|
485 |
|
486 return recurrenceEvent; |
|
487 } |
|
488 |
|
489 // --------------------------------------------------------------------------- |
|
490 // CESMRMeetingRequestEntry::SetRecurrenceL |
|
491 // |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 void CESMRMeetingRequestEntry::SetRecurrenceL( |
|
495 TESMRRecurrenceValue aRecurrence, |
|
496 TTime aUntil ) |
|
497 { |
|
498 FUNC_LOG; |
|
499 |
|
500 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
501 |
|
502 // Check if this entry's recurrence can be edited |
|
503 if ( !CanSetRecurrenceL() ) |
|
504 { |
|
505 User::Leave( KErrNotSupported ); |
|
506 } |
|
507 |
|
508 if ( aRecurrence != ERecurrenceNot && |
|
509 MESMRCalEntry::EESMRAllInSeries != iRecurrenceModRule ) |
|
510 { |
|
511 // Make sure that mod rule is correct |
|
512 SetModifyingRuleL( |
|
513 MESMRCalEntry::EESMRAllInSeries ); |
|
514 } |
|
515 |
|
516 CESMRRecurrenceInfoHandler* recurrenceHandler = |
|
517 CESMRRecurrenceInfoHandler::NewLC( *iEntry ); |
|
518 |
|
519 recurrenceHandler->SetRecurrenceL( aRecurrence, aUntil ); |
|
520 |
|
521 CleanupStack::PopAndDestroy( recurrenceHandler ); |
|
522 |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------------------------- |
|
526 // CESMRMeetingRequestEntry::GetRecurrenceL |
|
527 // |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 void CESMRMeetingRequestEntry::GetRecurrenceL( |
|
531 TESMRRecurrenceValue& aRecurrence, |
|
532 TTime& aUntil) const |
|
533 { |
|
534 FUNC_LOG; |
|
535 |
|
536 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
537 |
|
538 CESMRRecurrenceInfoHandler* recurrenceHandler = |
|
539 CESMRRecurrenceInfoHandler::NewLC( *iEntry ); |
|
540 |
|
541 recurrenceHandler->GetRecurrenceL( aRecurrence, aUntil ); |
|
542 CleanupStack::PopAndDestroy( recurrenceHandler ); |
|
543 |
|
544 } |
|
545 |
|
546 // --------------------------------------------------------------------------- |
|
547 // CESMRMeetingRequestEntry::RecurrenceModRule |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 MESMRCalEntry::TESMRRecurrenceModifyingRule |
|
551 CESMRMeetingRequestEntry::RecurrenceModRule() const |
|
552 { |
|
553 return iRecurrenceModRule; |
|
554 } |
|
555 |
|
556 // --------------------------------------------------------------------------- |
|
557 // CESMRMeetingRequestEntry::SetModifyingRuleL |
|
558 // --------------------------------------------------------------------------- |
|
559 // |
|
560 void CESMRMeetingRequestEntry::SetModifyingRuleL( |
|
561 TESMRRecurrenceModifyingRule aRule ) |
|
562 { |
|
563 FUNC_LOG; |
|
564 |
|
565 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
566 |
|
567 CESMRRecurrenceInfoHandler* recHandler = |
|
568 CESMRRecurrenceInfoHandler::NewL( *iOrginalEntry ); |
|
569 CleanupStack::PushL( recHandler ); |
|
570 |
|
571 TESMRRecurrenceValue orginalRecurrence; |
|
572 TTime orginalUntil; |
|
573 |
|
574 recHandler->GetRecurrenceL( |
|
575 orginalRecurrence, |
|
576 orginalUntil); |
|
577 |
|
578 CleanupStack::PopAndDestroy( recHandler ); |
|
579 recHandler = NULL; |
|
580 |
|
581 |
|
582 if ( MESMRCalEntry::EESMRAllInSeries == aRule && |
|
583 IsStoredL() && !IsForwardedL() && !IsOpenedFromMail() ) |
|
584 { |
|
585 // When we want to modify series of recurrence entries --> |
|
586 // Parent entry is modified |
|
587 |
|
588 TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *iEntry ) ); |
|
589 if ( ERecurrenceNot == orginalRecurrence && !modifyingEntry ) |
|
590 { |
|
591 // Orginal entry was not recurrent event |
|
592 // No need to fect instance at all |
|
593 // For modifying entries we need to fetch the original parent entry |
|
594 iRecurrenceModRule = aRule; |
|
595 return; |
|
596 } |
|
597 |
|
598 CCalInstance* instance = NULL; |
|
599 TRAPD(err, instance = InstanceL() ); |
|
600 if( KErrNotFound != err ) |
|
601 { |
|
602 User::LeaveIfError( err ); |
|
603 } |
|
604 |
|
605 if ( instance ) |
|
606 { |
|
607 CleanupStack::PushL( instance ); |
|
608 |
|
609 CCalEntry::TMethod entryMethod( iEntry->MethodL() ); |
|
610 |
|
611 delete iEntry; |
|
612 iEntry = NULL; |
|
613 |
|
614 delete iForwardEntry; |
|
615 iForwardEntry = NULL; |
|
616 |
|
617 delete iOrginalEntry; |
|
618 iOrginalEntry = NULL; |
|
619 |
|
620 RCPointerArray<CCalEntry> entries; |
|
621 CleanupClosePushL( entries ); |
|
622 |
|
623 iCalDb.NormalDbEntryView()->FetchL( |
|
624 instance->Entry().UidL(), entries ); |
|
625 |
|
626 TInt parentIndex( KErrNotFound ); |
|
627 TInt entryCount( entries.Count() ); |
|
628 for ( TInt i(0); i < entryCount && KErrNotFound == parentIndex; ++i ) |
|
629 { |
|
630 TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *entries[i]) ); |
|
631 if ( !modifyingEntry ) |
|
632 { |
|
633 parentIndex = i; |
|
634 } |
|
635 } |
|
636 |
|
637 __ASSERT_DEBUG( KErrNotFound != parentIndex, Panic(EESMRParentNotFound) ); |
|
638 |
|
639 CCalEntry& parent = *entries[parentIndex]; |
|
640 |
|
641 TPtrC description( parent.DescriptionL() ); |
|
642 |
|
643 iEntry = ESMRHelper::CopyEntryL( |
|
644 parent, |
|
645 parent.MethodL(), |
|
646 ESMRHelper::ECopyFull ); |
|
647 |
|
648 CESMRFsMailboxUtils* fsMbUtils = |
|
649 CESMRFsMailboxUtils::NewL( iMRMailboxUtils ); |
|
650 CleanupStack::PushL( fsMbUtils ); |
|
651 |
|
652 fsMbUtils->SetPhoneOwnerL( *iEntry ); |
|
653 CleanupStack::PopAndDestroy( fsMbUtils ); |
|
654 fsMbUtils = NULL; |
|
655 |
|
656 // Adjust parent entry's start and end time to entry |
|
657 TCalTime start; |
|
658 TCalTime end; |
|
659 |
|
660 CESMRRecurrenceInfoHandler* recurrenceHandler = |
|
661 CESMRRecurrenceInfoHandler::NewLC( parent ); |
|
662 |
|
663 recurrenceHandler->GetFirstInstanceTimeL( start, end ); |
|
664 CleanupStack::PopAndDestroy( recurrenceHandler ); |
|
665 recurrenceHandler = NULL; |
|
666 |
|
667 iEntry->SetStartAndEndTimeL( start, end ); |
|
668 |
|
669 iOrginalEntry = ESMRHelper::CopyEntryL( |
|
670 *iEntry, |
|
671 iEntry->MethodL(), |
|
672 ESMRHelper::ECopyFull ); |
|
673 |
|
674 if ( iEntry->MethodL() != entryMethod ) |
|
675 { |
|
676 iEntry->SetMethodL( entryMethod ); |
|
677 iOrginalEntry->SetMethodL( entryMethod ); |
|
678 } |
|
679 |
|
680 iEntry->SetDescriptionL( description ); |
|
681 iOrginalEntry->SetDescriptionL( description ); |
|
682 |
|
683 CleanupStack::PopAndDestroy(); // entries |
|
684 CleanupStack::PopAndDestroy( instance ); |
|
685 |
|
686 if ( EESMRRoleOrganizer == RoleL() && IsStoredL() ) |
|
687 { |
|
688 // Increase sequence number |
|
689 TInt seqNo( iEntry->SequenceNumberL() + 1); |
|
690 iEntry->SetSequenceNumberL( seqNo ); |
|
691 iOrginalEntry->SetSequenceNumberL( seqNo ); |
|
692 } |
|
693 } |
|
694 } |
|
695 |
|
696 iRecurrenceModRule = aRule; |
|
697 |
|
698 } |
|
699 |
|
700 // --------------------------------------------------------------------------- |
|
701 // CESMRMeetingRequestEntry::SetAllDayEventL |
|
702 // |
|
703 // --------------------------------------------------------------------------- |
|
704 // |
|
705 void CESMRMeetingRequestEntry::SetAllDayEventL( |
|
706 TTime aStartDate, |
|
707 TTime aEndDate ) |
|
708 { |
|
709 FUNC_LOG; |
|
710 |
|
711 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
712 |
|
713 TCalTime startTime; |
|
714 TCalTime stopTime; |
|
715 |
|
716 TDateTime start; |
|
717 TDateTime end; |
|
718 |
|
719 // set the start time to 0:00 |
|
720 start.Set( aStartDate.DateTime().Year(), |
|
721 aStartDate.DateTime().Month(), |
|
722 aStartDate.DateTime().Day(), |
|
723 KZero, |
|
724 KZero, |
|
725 KZero, |
|
726 KZero); |
|
727 |
|
728 // set the end date to next day from given end date since |
|
729 // all day event should last 24 hours. |
|
730 TTime endDate = aEndDate + TTimeIntervalDays( 1 ); |
|
731 end.Set( endDate.DateTime().Year(), |
|
732 endDate.DateTime().Month(), |
|
733 endDate.DateTime().Day(), |
|
734 KZero, |
|
735 KZero, |
|
736 KZero, |
|
737 KZero ); |
|
738 |
|
739 startTime.SetTimeLocalL( start ); |
|
740 stopTime.SetTimeLocalL( end ); |
|
741 |
|
742 iEntry->SetStartAndEndTimeL( startTime, stopTime ); |
|
743 |
|
744 } |
|
745 |
|
746 // --------------------------------------------------------------------------- |
|
747 // CESMRMeetingRequestEntry::IsAllDayEventL |
|
748 // |
|
749 // --------------------------------------------------------------------------- |
|
750 // |
|
751 TBool CESMRMeetingRequestEntry::IsAllDayEventL() const |
|
752 { |
|
753 FUNC_LOG; |
|
754 |
|
755 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
756 |
|
757 TBool allDayEvent(EFalse); |
|
758 |
|
759 TCalTime startTime = iEntry->StartTimeL(); |
|
760 TCalTime stopTime = iEntry->EndTimeL(); |
|
761 |
|
762 TTimeIntervalHours hoursBetweenStartAndEnd; |
|
763 stopTime.TimeLocalL().HoursFrom( |
|
764 startTime.TimeLocalL(), |
|
765 hoursBetweenStartAndEnd ); |
|
766 |
|
767 TCalTime::TTimeMode mode = startTime.TimeMode(); |
|
768 |
|
769 TInt hoursBetweenStartAndEndAsInt( hoursBetweenStartAndEnd.Int() ); |
|
770 TInt alldayDivident( hoursBetweenStartAndEndAsInt % KHoursInDay ); |
|
771 |
|
772 if ( hoursBetweenStartAndEndAsInt&& KZero == alldayDivident ) |
|
773 { |
|
774 TDateTime startTimeLocal = startTime.TimeLocalL().DateTime(); |
|
775 TDateTime stopTimeLocal = stopTime.TimeLocalL().DateTime(); |
|
776 |
|
777 if ( startTimeLocal.Hour() == stopTimeLocal.Hour() && |
|
778 startTimeLocal.Minute() == stopTimeLocal.Minute() && |
|
779 startTimeLocal.Second() == stopTimeLocal.Second() ) |
|
780 { |
|
781 allDayEvent = ETrue; |
|
782 } |
|
783 } |
|
784 |
|
785 |
|
786 return allDayEvent; |
|
787 } |
|
788 |
|
789 // --------------------------------------------------------------------------- |
|
790 // CESMRMeetingRequestEntry::IsStoredL |
|
791 // --------------------------------------------------------------------------- |
|
792 // |
|
793 TBool CESMRMeetingRequestEntry::IsStoredL() const |
|
794 { |
|
795 FUNC_LOG; |
|
796 |
|
797 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
798 |
|
799 TBool ret(EFalse); |
|
800 CCalEntry* dbEntry = NULL; |
|
801 |
|
802 TRAPD( err, dbEntry = iCalDb.FetchEntryL( |
|
803 iEntry->UidL(), |
|
804 iEntry->RecurrenceIdL() ) ); |
|
805 |
|
806 if ( KErrNotFound == err ) |
|
807 { |
|
808 // Error has occured while retrieving an entry |
|
809 ret = EFalse; |
|
810 } |
|
811 else if ( dbEntry) |
|
812 { |
|
813 // Entry was found from the calendar db --> it is stored for sure. |
|
814 ret = ETrue; |
|
815 } |
|
816 |
|
817 delete dbEntry; |
|
818 |
|
819 |
|
820 return ret; |
|
821 } |
|
822 |
|
823 // --------------------------------------------------------------------------- |
|
824 // CESMRMeetingRequestEntry::IsSentL |
|
825 // --------------------------------------------------------------------------- |
|
826 // |
|
827 TBool CESMRMeetingRequestEntry::IsSentL() const |
|
828 { |
|
829 FUNC_LOG; |
|
830 |
|
831 __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) ); |
|
832 |
|
833 TBool retVal( EFalse ); |
|
834 |
|
835 if ( EESMRRoleOrganizer == RoleL() ) |
|
836 { |
|
837 CCalEntry::TStatus status( iOrginalEntry->StatusL() ); |
|
838 if ( CCalEntry::ENullStatus != status ) |
|
839 { // When we send a request for the first time we set |
|
840 // it's status to some other value than ENullStatus |
|
841 retVal = ETrue; |
|
842 } |
|
843 } |
|
844 else |
|
845 { |
|
846 // In attendee mode, we have sent the entry, if it is stored to |
|
847 // calendar db and status is not declined. Declined entries are |
|
848 // not stored to calendar db. |
|
849 TESMRAttendeeStatus currentStatus( AttendeeStatusL() ); |
|
850 if ( IsStoredL() && EESMRAttendeeStatusDecline != currentStatus) |
|
851 { |
|
852 retVal = ETrue; |
|
853 } |
|
854 } |
|
855 |
|
856 |
|
857 return retVal; |
|
858 } |
|
859 |
|
860 // --------------------------------------------------------------------------- |
|
861 // CESMRMeetingRequestEntry::IsEntryEditedL |
|
862 // |
|
863 // --------------------------------------------------------------------------- |
|
864 // |
|
865 TBool CESMRMeetingRequestEntry::IsEntryEditedL() const |
|
866 { |
|
867 FUNC_LOG; |
|
868 |
|
869 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
870 __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) ); |
|
871 |
|
872 TBool edited( EFalse ); |
|
873 |
|
874 if ( iOrginalEntry ) |
|
875 { // edited if differs from the db entry |
|
876 edited = !( iEntry->CompareL( *iOrginalEntry ) ); |
|
877 |
|
878 TESMRRole role( RoleL() ); |
|
879 if ( !edited && EESMRRoleOrganizer != role ) |
|
880 { |
|
881 // CCalEntry::CompareL does not compare attedee statuses |
|
882 CCalAttendee* dbAttendee = |
|
883 iMRMailboxUtils.ThisAttendeeL( *iOrginalEntry ); |
|
884 |
|
885 CCalAttendee* me = |
|
886 iMRMailboxUtils.ThisAttendeeL( *iEntry ); |
|
887 |
|
888 if ( dbAttendee && me ) |
|
889 { |
|
890 edited = dbAttendee->StatusL() != me->StatusL(); |
|
891 } |
|
892 } |
|
893 if ( !edited && EESMRRoleOrganizer == role && |
|
894 iEntry->MethodL() != iOrginalEntry->MethodL() ) |
|
895 { |
|
896 // For organizer CCalEntry::Compare does not compare entry's |
|
897 // method at all --> Need to compare ourselves. |
|
898 edited = ETrue; |
|
899 } |
|
900 |
|
901 // CCalEntry's CompareL doesn't check the priority value: |
|
902 if ( iOrginalEntry->PriorityL() != iEntry->PriorityL() ) |
|
903 { |
|
904 edited = ETrue; |
|
905 } |
|
906 |
|
907 TPtrC description( iEntry->DescriptionL() ); |
|
908 if ( description.CompareF( iOrginalEntry->DescriptionL() ) ) |
|
909 { |
|
910 edited = ETrue; |
|
911 } |
|
912 |
|
913 TPtrC location( iEntry->LocationL() ); |
|
914 if ( location.CompareF( iOrginalEntry->LocationL() ) ) |
|
915 { |
|
916 edited = ETrue; |
|
917 } |
|
918 |
|
919 } |
|
920 |
|
921 |
|
922 |
|
923 return edited; |
|
924 } |
|
925 |
|
926 // --------------------------------------------------------------------------- |
|
927 // CESMRMeetingRequestEntry::GetAlarmL |
|
928 // --------------------------------------------------------------------------- |
|
929 // |
|
930 void CESMRMeetingRequestEntry::GetAlarmL( |
|
931 MESMRCalEntry::TESMRAlarmType& aAlarmType, |
|
932 TTime &aAlarmTime ) |
|
933 { |
|
934 FUNC_LOG; |
|
935 |
|
936 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
937 |
|
938 aAlarmType = MESMRCalEntry::EESMRAlarmNotFound; |
|
939 aAlarmTime = Time::NullTTime(); |
|
940 |
|
941 TFileName alarmInfoResource; |
|
942 ESMRHelper::LocateResourceFile( |
|
943 KAlarmInfoResource, |
|
944 KDC_RESOURCE_FILES_DIR, |
|
945 alarmInfoResource); |
|
946 |
|
947 |
|
948 CESMRAlarmInfoHandler* alarmInfoHandler = |
|
949 CESMRAlarmInfoHandler::NewLC(); |
|
950 |
|
951 alarmInfoHandler->ReadFromResourceL( |
|
952 alarmInfoResource, |
|
953 ESRM_ALARM_INFO_TABLE ); |
|
954 |
|
955 TRAPD( err, |
|
956 alarmInfoHandler->GetAbsoluteAlarmTimeL(*iEntry, aAlarmTime) ); |
|
957 |
|
958 if ( KErrNone == err ) |
|
959 { |
|
960 aAlarmType = MESMRCalEntry::EESMRAlarmAbsolute; |
|
961 |
|
962 // only meeting request that is not allday event can have |
|
963 // relative alarm: |
|
964 if ( !IsAllDayEventL() ) |
|
965 { |
|
966 TESMRAlarmInfo alarmInfo; |
|
967 TRAP( err, |
|
968 alarmInfoHandler->GetAlarmInfoObjectL(*iEntry, alarmInfo) ); |
|
969 |
|
970 if ( KErrNone == err ) |
|
971 { |
|
972 aAlarmType = MESMRCalEntry::EESMRAlarmRelative; |
|
973 if( alarmInfo.iRelativeAlarmInSeconds < KZero ) |
|
974 { |
|
975 aAlarmType = MESMRCalEntry::EESMRAlarmNotFound; |
|
976 } |
|
977 } |
|
978 } |
|
979 } |
|
980 |
|
981 CleanupStack::PopAndDestroy( alarmInfoHandler ); |
|
982 |
|
983 } |
|
984 |
|
985 |
|
986 // --------------------------------------------------------------------------- |
|
987 // CESMRMeetingRequestEntry::OriginalEntry |
|
988 // --------------------------------------------------------------------------- |
|
989 // |
|
990 const CCalEntry& CESMRMeetingRequestEntry::OriginalEntry() |
|
991 { |
|
992 FUNC_LOG; |
|
993 return *iOrginalEntry; |
|
994 } |
|
995 |
|
996 |
|
997 // --------------------------------------------------------------------------- |
|
998 // CESMRMeetingRequestEntry::RoleL |
|
999 // --------------------------------------------------------------------------- |
|
1000 // |
|
1001 TESMRRole CESMRMeetingRequestEntry::RoleL() const |
|
1002 { |
|
1003 FUNC_LOG; |
|
1004 |
|
1005 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1006 |
|
1007 CESMRCalUserUtil* caluserUtil = CESMRCalUserUtil::NewLC( *iEntry ); |
|
1008 TESMRRole role = caluserUtil->PhoneOwnerRoleL(); |
|
1009 CleanupStack::PopAndDestroy( caluserUtil ); |
|
1010 |
|
1011 |
|
1012 return role; |
|
1013 } |
|
1014 |
|
1015 // --------------------------------------------------------------------------- |
|
1016 // CESMRMeetingRequestEntry::Conflicts |
|
1017 // --------------------------------------------------------------------------- |
|
1018 // |
|
1019 TBool CESMRMeetingRequestEntry::Conflicts() const |
|
1020 { |
|
1021 FUNC_LOG; |
|
1022 return iConflictsExists; |
|
1023 } |
|
1024 |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // CESMRMeetingRequestEntry::MarkMeetingCancelledL |
|
1027 // --------------------------------------------------------------------------- |
|
1028 // |
|
1029 void CESMRMeetingRequestEntry::MarkMeetingCancelledL() |
|
1030 { |
|
1031 FUNC_LOG; |
|
1032 |
|
1033 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1034 |
|
1035 TESMRRole role = RoleL(); |
|
1036 |
|
1037 if ( EESMRRoleOrganizer == role ) |
|
1038 { |
|
1039 iEntry->SetMethodL( CCalEntry::EMethodCancel ); |
|
1040 iEntry->SetStatusL( CCalEntry::ECancelled ); |
|
1041 } |
|
1042 else if ( EESMRRoleRequiredAttendee == role || |
|
1043 EESMRRoleOptionalAttendee == role || |
|
1044 EESMRRoleNonParticipant == role ) |
|
1045 { |
|
1046 ConstructReplyL( EESMRAttendeeStatusDecline ); |
|
1047 } |
|
1048 |
|
1049 } |
|
1050 |
|
1051 // --------------------------------------------------------------------------- |
|
1052 // CESMRMeetingRequestEntry::ConstructReplyL |
|
1053 // |
|
1054 // --------------------------------------------------------------------------- |
|
1055 // |
|
1056 void CESMRMeetingRequestEntry::ConstructReplyL( |
|
1057 TESMRAttendeeStatus aStatus ) |
|
1058 { |
|
1059 FUNC_LOG; |
|
1060 |
|
1061 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1062 |
|
1063 CCalAttendee* attendee = |
|
1064 iMRMailboxUtils.ThisAttendeeL( *iEntry ); |
|
1065 |
|
1066 if ( !attendee ) |
|
1067 { |
|
1068 |
|
1069 User::Leave( KErrNotFound ); |
|
1070 } |
|
1071 |
|
1072 CCalAttendee::TCalStatus status( |
|
1073 CCalAttendee::EDeclined ); |
|
1074 |
|
1075 CCalEntry::TStatus entryStatus = CCalEntry::ENullStatus; |
|
1076 switch ( aStatus ) |
|
1077 { |
|
1078 case EESMRAttendeeStatusAccept: |
|
1079 status = CCalAttendee::EAccepted; |
|
1080 entryStatus = CCalEntry::EConfirmed; |
|
1081 break; |
|
1082 |
|
1083 case EESMRAttendeeStatusTentative: |
|
1084 status = CCalAttendee::ETentative; |
|
1085 entryStatus = CCalEntry::ETentative; |
|
1086 break; |
|
1087 case EESMRAttendeeStatusDecline: |
|
1088 status = CCalAttendee::EDeclined; |
|
1089 entryStatus = CCalEntry::ECancelled; |
|
1090 break; |
|
1091 default: |
|
1092 // This should not occur |
|
1093 __ASSERT_DEBUG( |
|
1094 EFalse, |
|
1095 Panic( EESMRInvalidReplyType ) ); |
|
1096 |
|
1097 User::Leave( KErrArgument ); |
|
1098 break; |
|
1099 } |
|
1100 |
|
1101 attendee->SetStatusL(status); |
|
1102 iEntry->SetStatusL(entryStatus); |
|
1103 |
|
1104 iEntry->SetMethodL( CCalEntry::EMethodReply ); |
|
1105 |
|
1106 } |
|
1107 |
|
1108 // --------------------------------------------------------------------------- |
|
1109 // CESMRMeetingRequestEntry::IsEntryOutOfDateL |
|
1110 // |
|
1111 // --------------------------------------------------------------------------- |
|
1112 // |
|
1113 TBool CESMRMeetingRequestEntry::IsEntryOutOfDateL() const |
|
1114 { |
|
1115 FUNC_LOG; |
|
1116 |
|
1117 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1118 |
|
1119 TBool outOfDate( EFalse ); |
|
1120 |
|
1121 CCalEntry::TMethod method( iEntry->MethodL() ); |
|
1122 if ( IsOpenedFromMail() && |
|
1123 CCalEntry::EMethodCancel != method ) |
|
1124 { |
|
1125 CCalEntry* dbEntry = NULL; |
|
1126 |
|
1127 TRAP_IGNORE( dbEntry = iCalDb.FetchEntryL( iEntry->UidL(), |
|
1128 iEntry->RecurrenceIdL() ) ); |
|
1129 |
|
1130 CleanupStack::PushL( dbEntry ); |
|
1131 if ( dbEntry ) |
|
1132 { |
|
1133 TInt currentSeqNo( iEntry->SequenceNumberL() ); |
|
1134 TInt dbEntrySeqNo( dbEntry->SequenceNumberL() ); |
|
1135 |
|
1136 if ( currentSeqNo < dbEntrySeqNo ) |
|
1137 { |
|
1138 outOfDate = ETrue; |
|
1139 } |
|
1140 } |
|
1141 CleanupStack::PopAndDestroy( dbEntry ); |
|
1142 } |
|
1143 |
|
1144 |
|
1145 return outOfDate; |
|
1146 } |
|
1147 |
|
1148 // --------------------------------------------------------------------------- |
|
1149 // CESMRMeetingRequestEntry::IsMeetingCancelledL |
|
1150 // |
|
1151 // --------------------------------------------------------------------------- |
|
1152 // |
|
1153 TBool CESMRMeetingRequestEntry::IsMeetingCancelledL() const |
|
1154 { |
|
1155 FUNC_LOG; |
|
1156 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1157 |
|
1158 TBool retValue( EFalse ); |
|
1159 |
|
1160 CCalEntry::TMethod method( iEntry->MethodL() ); |
|
1161 |
|
1162 if ( CCalEntry::ECancelled == iEntry->StatusL() || |
|
1163 CCalEntry::EMethodCancel == method ) |
|
1164 { |
|
1165 retValue = ETrue; |
|
1166 } |
|
1167 |
|
1168 return retValue; |
|
1169 } |
|
1170 |
|
1171 // --------------------------------------------------------------------------- |
|
1172 // CESMRMeetingRequestEntry::AttendeeStatusL |
|
1173 // |
|
1174 // --------------------------------------------------------------------------- |
|
1175 // |
|
1176 TESMRAttendeeStatus CESMRMeetingRequestEntry::AttendeeStatusL() const |
|
1177 { |
|
1178 FUNC_LOG; |
|
1179 |
|
1180 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1181 |
|
1182 TESMRAttendeeStatus status( |
|
1183 EESMRAttendeeStatusDecline ); |
|
1184 |
|
1185 if ( iMRMailboxUtils.IsOrganizerL( *iEntry ) ) |
|
1186 { |
|
1187 |
|
1188 User::Leave( KErrNotFound ); |
|
1189 } |
|
1190 |
|
1191 CCalAttendee* attendee = iMRMailboxUtils.ThisAttendeeL( *iEntry ); |
|
1192 if (!attendee ) |
|
1193 { |
|
1194 User::Leave( KErrNotFound ); |
|
1195 } |
|
1196 |
|
1197 CCalAttendee::TCalStatus attendeeStatus( attendee->StatusL() ); |
|
1198 switch ( attendeeStatus ) |
|
1199 { |
|
1200 case CCalAttendee::EAccepted: |
|
1201 status = EESMRAttendeeStatusAccept; |
|
1202 break; |
|
1203 |
|
1204 case CCalAttendee::ETentative: |
|
1205 status = EESMRAttendeeStatusTentative; |
|
1206 break; |
|
1207 |
|
1208 case CCalAttendee::EDeclined: |
|
1209 status = EESMRAttendeeStatusDecline; |
|
1210 break; |
|
1211 |
|
1212 default: |
|
1213 status = EESMRAttendeeStatusDecline; |
|
1214 break; |
|
1215 } |
|
1216 |
|
1217 |
|
1218 return status; |
|
1219 } |
|
1220 |
|
1221 // --------------------------------------------------------------------------- |
|
1222 // CESMRMeetingRequestEntry::IsForwardedL |
|
1223 // |
|
1224 // --------------------------------------------------------------------------- |
|
1225 // |
|
1226 TBool CESMRMeetingRequestEntry::IsForwardedL() const |
|
1227 { |
|
1228 FUNC_LOG; |
|
1229 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1230 |
|
1231 TBool retValue( EFalse ); |
|
1232 if ( iForwardEntry ) |
|
1233 { |
|
1234 retValue = ETrue; |
|
1235 } |
|
1236 return retValue; |
|
1237 } |
|
1238 |
|
1239 // --------------------------------------------------------------------------- |
|
1240 // CESMRMeetingRequestEntry::SwitchToForwardL |
|
1241 // |
|
1242 // --------------------------------------------------------------------------- |
|
1243 // |
|
1244 void CESMRMeetingRequestEntry::SwitchToForwardL() |
|
1245 { |
|
1246 FUNC_LOG; |
|
1247 |
|
1248 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1249 |
|
1250 CCalEntry* temp = ESMRHelper::CopyEntryL( |
|
1251 *iEntry, |
|
1252 iEntry->MethodL(), |
|
1253 ESMRHelper::ECopyFull ); |
|
1254 |
|
1255 delete iForwardEntry; |
|
1256 iForwardEntry = temp; |
|
1257 |
|
1258 RPointerArray<CCalAttendee>& attendeeList = |
|
1259 iForwardEntry->AttendeesL(); |
|
1260 |
|
1261 while ( attendeeList.Count() ) |
|
1262 { |
|
1263 //remove attendees from entry that is to be forwarded |
|
1264 iForwardEntry->DeleteAttendeeL( KFirstIndex ); |
|
1265 } |
|
1266 |
|
1267 } |
|
1268 |
|
1269 // --------------------------------------------------------------------------- |
|
1270 // CESMRMeetingRequestEntry::SwitchToOrginalL |
|
1271 // |
|
1272 // --------------------------------------------------------------------------- |
|
1273 // |
|
1274 void CESMRMeetingRequestEntry::SwitchToOrginalL() |
|
1275 { |
|
1276 FUNC_LOG; |
|
1277 |
|
1278 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1279 |
|
1280 // We just delete the forwarded entry |
|
1281 delete iForwardEntry; |
|
1282 iForwardEntry = NULL; |
|
1283 |
|
1284 } |
|
1285 |
|
1286 // --------------------------------------------------------------------------- |
|
1287 // CESMRMeetingRequestEntry::SwitchToOrginalL |
|
1288 // |
|
1289 // --------------------------------------------------------------------------- |
|
1290 // |
|
1291 void CESMRMeetingRequestEntry::ConfirmEntryL() |
|
1292 { |
|
1293 FUNC_LOG; |
|
1294 |
|
1295 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1296 |
|
1297 if ( iForwardEntry && |
|
1298 iForwardEntry->StatusL() == CCalEntry::ENullStatus ) |
|
1299 { |
|
1300 iForwardEntry->SetStatusL( CCalEntry::EConfirmed ); |
|
1301 } |
|
1302 else if ( RoleL() == EESMRRoleOrganizer || |
|
1303 iEntry->StatusL() == CCalEntry::ENullStatus ) |
|
1304 { |
|
1305 iEntry->SetStatusL( CCalEntry::EConfirmed ); |
|
1306 } |
|
1307 |
|
1308 } |
|
1309 |
|
1310 // --------------------------------------------------------------------------- |
|
1311 // CESMRMeetingRequestEntry::OccursInPastL |
|
1312 // --------------------------------------------------------------------------- |
|
1313 // |
|
1314 TBool CESMRMeetingRequestEntry::OccursInPastL() const |
|
1315 { |
|
1316 FUNC_LOG; |
|
1317 |
|
1318 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1319 |
|
1320 TTime currentTimeUtc; |
|
1321 currentTimeUtc.UniversalTime(); |
|
1322 |
|
1323 TTime startTimeUtc = iEntry->StartTimeL().TimeUtcL(); |
|
1324 |
|
1325 |
|
1326 return (startTimeUtc < currentTimeUtc); |
|
1327 } |
|
1328 |
|
1329 // --------------------------------------------------------------------------- |
|
1330 // CESMRMeetingRequestEntry::EntryAttendeeInfoL |
|
1331 // --------------------------------------------------------------------------- |
|
1332 // |
|
1333 MESMRMeetingRequestEntry::TESMREntryInfo |
|
1334 CESMRMeetingRequestEntry::EntryAttendeeInfoL() const |
|
1335 { |
|
1336 FUNC_LOG; |
|
1337 |
|
1338 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1339 |
|
1340 #ifdef _DEBUG |
|
1341 |
|
1342 __ASSERT_DEBUG( EESMRRoleOrganizer != RoleL(), Panic(EESMRInvalidRole) ); |
|
1343 |
|
1344 #else |
|
1345 |
|
1346 if ( EESMRRoleOrganizer == RoleL() ) |
|
1347 { |
|
1348 // Info cannot be resolved in organzier role |
|
1349 User::Leave( KErrNotSupported ); |
|
1350 } |
|
1351 #endif |
|
1352 |
|
1353 TESMRAttendeeStatus attendeeStatus( |
|
1354 AttendeeStatusL() ); |
|
1355 |
|
1356 MESMRMeetingRequestEntry::TESMREntryInfo info = |
|
1357 EESMREntryInfoNormal; |
|
1358 |
|
1359 TBool isSent( IsSentL() ); |
|
1360 |
|
1361 if ( IsEntryOutOfDateL() ) |
|
1362 { |
|
1363 info = EESMREntryInfoOutOfDate; |
|
1364 } |
|
1365 else if( IsMeetingCancelledL() ) |
|
1366 { |
|
1367 info = EESMREntryInfoCancelled; |
|
1368 } |
|
1369 else if ( isSent ) |
|
1370 { |
|
1371 info = EESMREntryInfoAccepted; |
|
1372 if ( EESMRAttendeeStatusTentative == attendeeStatus ) |
|
1373 { |
|
1374 info = EESMREntryInfoTentativelyAccepted; |
|
1375 } |
|
1376 } |
|
1377 else if ( OccursInPastL() ) |
|
1378 { |
|
1379 info = EESMREntryInfoOccursInPast; |
|
1380 } |
|
1381 else if ( iConflictsExists ) |
|
1382 { |
|
1383 info = EESMREntryInfoConflicts; |
|
1384 } |
|
1385 |
|
1386 |
|
1387 return info; |
|
1388 } |
|
1389 |
|
1390 // --------------------------------------------------------------------------- |
|
1391 // CESMRMeetingRequestEntry::SetPriorityL |
|
1392 // --------------------------------------------------------------------------- |
|
1393 // |
|
1394 void CESMRMeetingRequestEntry::SetPriorityL( |
|
1395 TUint aPriority ) |
|
1396 { |
|
1397 FUNC_LOG; |
|
1398 |
|
1399 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1400 |
|
1401 iEntry->SetPriorityL( aPriority ); |
|
1402 |
|
1403 } |
|
1404 |
|
1405 // --------------------------------------------------------------------------- |
|
1406 // CESMRMeetingRequestEntry::GetPriorityL |
|
1407 // --------------------------------------------------------------------------- |
|
1408 // |
|
1409 TUint CESMRMeetingRequestEntry::GetPriorityL() const |
|
1410 { |
|
1411 FUNC_LOG; |
|
1412 |
|
1413 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1414 |
|
1415 TUint entryPriority = iEntry->PriorityL(); |
|
1416 |
|
1417 if ( entryPriority != EFSCalenMRPriorityLow && |
|
1418 entryPriority != EFSCalenMRPriorityNormal && |
|
1419 entryPriority != EFSCalenMRPriorityHigh ) |
|
1420 { |
|
1421 entryPriority = EFSCalenMRPriorityNormal; |
|
1422 } |
|
1423 |
|
1424 |
|
1425 return entryPriority; |
|
1426 } |
|
1427 |
|
1428 // --------------------------------------------------------------------------- |
|
1429 // CESMRMeetingRequestEntry::GetAttendeesL |
|
1430 // --------------------------------------------------------------------------- |
|
1431 // |
|
1432 void CESMRMeetingRequestEntry::GetAttendeesL( |
|
1433 RArray<CCalAttendee*>& aAttendeeArray, |
|
1434 TUint aFilterFlags ) const |
|
1435 { |
|
1436 FUNC_LOG; |
|
1437 |
|
1438 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1439 |
|
1440 CESMRCalUserUtil* caluserUtil = CESMRCalUserUtil::NewLC( *iEntry ); |
|
1441 caluserUtil->GetAttendeesL( aAttendeeArray, aFilterFlags ); |
|
1442 CleanupStack::PopAndDestroy( caluserUtil ); |
|
1443 |
|
1444 } |
|
1445 |
|
1446 // --------------------------------------------------------------------------- |
|
1447 // CESMRMeetingRequestEntry::ValidateEntryL |
|
1448 // --------------------------------------------------------------------------- |
|
1449 // |
|
1450 CCalEntry* CESMRMeetingRequestEntry::ValidateEntryL() |
|
1451 { |
|
1452 FUNC_LOG; |
|
1453 |
|
1454 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1455 __ASSERT_DEBUG( iOrginalEntry, Panic(EESMREntryNotExist ) ); |
|
1456 |
|
1457 CCalEntry* entry = NULL; |
|
1458 |
|
1459 if ( iForwardEntry ) |
|
1460 { |
|
1461 entry = ESMRHelper::CopyEntryL( |
|
1462 *iForwardEntry, |
|
1463 iForwardEntry->MethodL(), |
|
1464 ESMRHelper::ECopyFull ); |
|
1465 } |
|
1466 |
|
1467 if ( !entry && IsRecurrentEventL() && |
|
1468 EESMRThisOnly == iRecurrenceModRule && |
|
1469 !IsForwardedL() && IsStoredL() && |
|
1470 !ESMREntryHelper::IsModifyingEntryL(*iEntry) ) |
|
1471 { |
|
1472 |
|
1473 CCalInstance* instance = NULL; |
|
1474 TRAPD( err, instance = InstanceL() ); |
|
1475 if( KErrNotFound != err ) |
|
1476 { |
|
1477 User::LeaveIfError( err ); |
|
1478 } |
|
1479 |
|
1480 if ( instance ) |
|
1481 { |
|
1482 |
|
1483 CleanupStack::PushL( instance ); |
|
1484 CCalEntry& parent = instance->Entry(); |
|
1485 |
|
1486 entry = iCalDb.FetchEntryL( |
|
1487 parent.UidL(), |
|
1488 iOrginalEntry->StartTimeL() ); |
|
1489 |
|
1490 if ( !entry ) |
|
1491 { |
|
1492 |
|
1493 // copy global UID from the original entry |
|
1494 HBufC8* guid = parent.UidL().AllocLC(); |
|
1495 |
|
1496 // create new (child) entry |
|
1497 entry = CCalEntry::NewL( |
|
1498 parent.EntryTypeL(), |
|
1499 guid, |
|
1500 parent.MethodL(), |
|
1501 KZero, |
|
1502 iOrginalEntry->StartTimeL(), |
|
1503 CalCommon::EThisOnly ); |
|
1504 |
|
1505 CleanupStack::Pop( guid ); |
|
1506 guid = NULL; // ownership transferred |
|
1507 } |
|
1508 |
|
1509 CleanupStack::PopAndDestroy( instance ); |
|
1510 instance = NULL; // instance |
|
1511 CleanupStack::PushL( entry ); |
|
1512 |
|
1513 |
|
1514 CCalEntry::TMethod method( iEntry->MethodL() ); |
|
1515 |
|
1516 entry->CopyFromL( *iEntry, CCalEntry::EDontCopyId ); |
|
1517 entry->SetSequenceNumberL( KZero ); |
|
1518 entry->SetMethodL( method ); |
|
1519 entry->SetSummaryL( iEntry->SummaryL() ); |
|
1520 entry->SetLocalUidL( TCalLocalUid( 0 ) ); |
|
1521 entry->ClearRepeatingPropertiesL(); |
|
1522 |
|
1523 CleanupStack::Pop( entry ); |
|
1524 } |
|
1525 } |
|
1526 |
|
1527 if ( !entry ) |
|
1528 { |
|
1529 |
|
1530 entry = ESMRHelper::CopyEntryL( |
|
1531 *iEntry, |
|
1532 iEntry->MethodL(), |
|
1533 ESMRHelper::ECopyFull ); |
|
1534 |
|
1535 } |
|
1536 |
|
1537 |
|
1538 return entry; |
|
1539 } |
|
1540 |
|
1541 // --------------------------------------------------------------------------- |
|
1542 // CESMRMeetingRequestEntry::FetchConflictingEntriesL |
|
1543 // --------------------------------------------------------------------------- |
|
1544 // |
|
1545 TInt CESMRMeetingRequestEntry::FetchConflictingEntriesL( |
|
1546 RPointerArray<CCalEntry>& aEntryArray) |
|
1547 { |
|
1548 FUNC_LOG; |
|
1549 |
|
1550 TInt ret( KErrNone ); |
|
1551 |
|
1552 CESMRConflictChecker* conflictChecker = |
|
1553 CESMRConflictChecker::NewL(iCalDb); |
|
1554 CleanupStack::PushL( conflictChecker ); |
|
1555 |
|
1556 |
|
1557 conflictChecker->FindConflictsL( *iEntry, aEntryArray ); |
|
1558 |
|
1559 CleanupStack::PopAndDestroy( conflictChecker ); |
|
1560 |
|
1561 if ( aEntryArray.Count() == 0 ) |
|
1562 { |
|
1563 ret = KErrNotFound; |
|
1564 } |
|
1565 |
|
1566 |
|
1567 return ret; |
|
1568 } |
|
1569 |
|
1570 // --------------------------------------------------------------------------- |
|
1571 // CESMRMeetingRequestEntry::IsSyncObjectPresent |
|
1572 // --------------------------------------------------------------------------- |
|
1573 // |
|
1574 TBool CESMRMeetingRequestEntry::IsSyncObjectPresent() const |
|
1575 { |
|
1576 FUNC_LOG; |
|
1577 TBool retValue(EFalse); |
|
1578 |
|
1579 if ( iESMRInputParams && iESMRInputParams->iMRInfoObject) |
|
1580 { |
|
1581 retValue = ETrue; |
|
1582 } |
|
1583 |
|
1584 return retValue; |
|
1585 } |
|
1586 |
|
1587 // --------------------------------------------------------------------------- |
|
1588 // CESMRMeetingRequestEntry::SyncObjectL |
|
1589 // --------------------------------------------------------------------------- |
|
1590 // |
|
1591 MMRInfoObject& CESMRMeetingRequestEntry::SyncObjectL() |
|
1592 { |
|
1593 FUNC_LOG; |
|
1594 if ( !IsSyncObjectPresent() ) |
|
1595 { |
|
1596 User::Leave(KErrNotSupported); |
|
1597 } |
|
1598 |
|
1599 return *iESMRInputParams->iMRInfoObject; |
|
1600 } |
|
1601 |
|
1602 // --------------------------------------------------------------------------- |
|
1603 // CESMRMeetingRequestEntry::ValidateSyncObjectL |
|
1604 // --------------------------------------------------------------------------- |
|
1605 // |
|
1606 MMRInfoObject& CESMRMeetingRequestEntry::ValidateSyncObjectL() |
|
1607 { |
|
1608 FUNC_LOG; |
|
1609 if ( EESMRRoleOrganizer == RoleL() ) |
|
1610 { |
|
1611 User::Leave( KErrNotSupported ); |
|
1612 } |
|
1613 |
|
1614 MMRInfoObject& syncObject = SyncObjectL(); |
|
1615 |
|
1616 CCalAttendee* thisAttendee = |
|
1617 iMRMailboxUtils.ThisAttendeeL( *iEntry ); |
|
1618 |
|
1619 RPointerArray<MMRAttendee> attendeeArray = |
|
1620 syncObject.AttendeesL(); |
|
1621 |
|
1622 TBool found( EFalse ); |
|
1623 TInt attendeeCount( attendeeArray.Count() ); |
|
1624 for (TInt i (0); i < attendeeCount && !found; ++i ) |
|
1625 { |
|
1626 MMRAttendee* attendee = attendeeArray[i]; |
|
1627 |
|
1628 TPtrC calEntryAddress( thisAttendee->Address() ); |
|
1629 TPtrC infoAddress( attendee->Address() ); |
|
1630 if ( KZero == infoAddress.Compare(calEntryAddress ) ) |
|
1631 { |
|
1632 found = ETrue; |
|
1633 |
|
1634 MMRInfoObject::TResponse entryResp( |
|
1635 MMRInfoObject::EMrCmdResponseAccept ); |
|
1636 |
|
1637 CCalAttendee::TCalStatus calEntryAttStatus( |
|
1638 thisAttendee->StatusL() ); |
|
1639 |
|
1640 MMRAttendee::TAttendeeStatus infoAttStatus( |
|
1641 MMRAttendee::EMRAttendeeActionAccepted ); |
|
1642 |
|
1643 if ( CCalAttendee::ETentative == calEntryAttStatus) |
|
1644 { |
|
1645 infoAttStatus = MMRAttendee::EMRAttendeeActionTentative; |
|
1646 entryResp = MMRInfoObject::EMrCmdResponseTentative; |
|
1647 } |
|
1648 else if ( CCalAttendee::EDeclined == calEntryAttStatus || |
|
1649 CCalEntry::EMethodCancel == iEntry->MethodL() ) |
|
1650 { |
|
1651 infoAttStatus = MMRAttendee::EMRAttendeeActionDeclined; |
|
1652 entryResp = MMRInfoObject::EMrCmdResponseDecline; |
|
1653 } |
|
1654 |
|
1655 attendee->SetAttendeeStatusL(infoAttStatus); |
|
1656 syncObject.SetMRResponseL( entryResp ); |
|
1657 } |
|
1658 } |
|
1659 |
|
1660 __ASSERT_DEBUG( found, Panic(EESMRNoInfoObjectAttendeeFound) ); |
|
1661 |
|
1662 return syncObject; |
|
1663 } |
|
1664 |
|
1665 // --------------------------------------------------------------------------- |
|
1666 // CESMRMeetingRequestEntry::StartupParameters |
|
1667 // --------------------------------------------------------------------------- |
|
1668 // |
|
1669 TBool CESMRMeetingRequestEntry::StartupParameters( |
|
1670 TESMRInputParams& aStartupParams) const |
|
1671 { |
|
1672 FUNC_LOG; |
|
1673 TBool retValue( EFalse ); |
|
1674 |
|
1675 if ( iESMRInputParams ) |
|
1676 { |
|
1677 retValue = ETrue; |
|
1678 |
|
1679 aStartupParams.iCalEntry = iESMRInputParams->iCalEntry; |
|
1680 aStartupParams.iMRInfoObject = iESMRInputParams->iMRInfoObject; |
|
1681 aStartupParams.iMailMessage = iESMRInputParams->iMailMessage; |
|
1682 aStartupParams.iMailClient = iESMRInputParams->iMailClient; |
|
1683 aStartupParams.iAttachmentInfo = iESMRInputParams->iAttachmentInfo; |
|
1684 aStartupParams.iSpare = iESMRInputParams->iSpare; |
|
1685 } |
|
1686 return retValue; |
|
1687 } |
|
1688 |
|
1689 // --------------------------------------------------------------------------- |
|
1690 // CESMRMeetingRequestEntry::AttendeeCountL |
|
1691 // --------------------------------------------------------------------------- |
|
1692 // |
|
1693 TInt CESMRMeetingRequestEntry::AttendeeCountL( |
|
1694 TUint aFilterFlags ) const |
|
1695 { |
|
1696 FUNC_LOG; |
|
1697 |
|
1698 TInt attendeeCount(0); |
|
1699 |
|
1700 RArray<CCalAttendee*> attendeeArray; |
|
1701 CleanupClosePushL( attendeeArray ); |
|
1702 |
|
1703 GetAttendeesL( |
|
1704 attendeeArray, |
|
1705 aFilterFlags ); |
|
1706 |
|
1707 attendeeCount = attendeeArray.Count(); |
|
1708 |
|
1709 CleanupStack::PopAndDestroy( &attendeeArray ); |
|
1710 |
|
1711 |
|
1712 return attendeeCount; |
|
1713 } |
|
1714 |
|
1715 // --------------------------------------------------------------------------- |
|
1716 // CESMRMeetingRequestEntry::RemoveInstanceFromSeriesL |
|
1717 // --------------------------------------------------------------------------- |
|
1718 // |
|
1719 CCalEntry* CESMRMeetingRequestEntry::RemoveInstanceFromSeriesL() |
|
1720 { |
|
1721 FUNC_LOG; |
|
1722 |
|
1723 CCalEntry* retEntry = NULL; |
|
1724 |
|
1725 if ( IsRecurrentEventL() && |
|
1726 EESMRThisOnly == iRecurrenceModRule && |
|
1727 !IsForwardedL() ) |
|
1728 { |
|
1729 CCalInstance* instance = NULL; |
|
1730 TRAPD( err, instance = InstanceL() ); |
|
1731 if( KErrNotFound != err ) |
|
1732 { |
|
1733 User::LeaveIfError( err ); |
|
1734 } |
|
1735 |
|
1736 if ( instance ) |
|
1737 { |
|
1738 CleanupStack::PushL( instance ); |
|
1739 |
|
1740 CCalEntry& parentEntry = instance->Entry(); |
|
1741 retEntry = ESMRHelper::CopyEntryL( |
|
1742 parentEntry, |
|
1743 parentEntry.MethodL(), |
|
1744 ESMRHelper::ECopyFull ); |
|
1745 |
|
1746 CleanupStack::PopAndDestroy( instance ); |
|
1747 instance = NULL; |
|
1748 |
|
1749 CleanupStack::PushL( retEntry ); |
|
1750 |
|
1751 CESMRRecurrenceInfoHandler* recurrenceHandler = |
|
1752 CESMRRecurrenceInfoHandler::NewLC( *retEntry ); |
|
1753 |
|
1754 TCalTime orginalInstanceTime; |
|
1755 orginalInstanceTime.SetTimeUtcL( |
|
1756 iOrginalEntry->StartTimeL().TimeUtcL() ); |
|
1757 |
|
1758 recurrenceHandler->RemoveInstanceL( orginalInstanceTime ); |
|
1759 |
|
1760 CleanupStack::PopAndDestroy( recurrenceHandler ); |
|
1761 CleanupStack::Pop( retEntry ); |
|
1762 } |
|
1763 } |
|
1764 else |
|
1765 { |
|
1766 User::Leave( KErrNotSupported ); |
|
1767 } |
|
1768 |
|
1769 |
|
1770 return retEntry; |
|
1771 } |
|
1772 |
|
1773 // --------------------------------------------------------------------------- |
|
1774 // CESMRMeetingRequestEntry::SetDefaultValuesToEntryL |
|
1775 // --------------------------------------------------------------------------- |
|
1776 // |
|
1777 void CESMRMeetingRequestEntry::SetDefaultValuesToEntryL() |
|
1778 { |
|
1779 FUNC_LOG; |
|
1780 |
|
1781 if ( !IsStoredL() ) |
|
1782 { |
|
1783 SetPriorityL( EFSCalenMRPriorityNormal ); |
|
1784 |
|
1785 // Get default alarm time from central repository |
|
1786 TInt defaultAlarmTime=0; |
|
1787 CRepository* repository = CRepository::NewLC( KCRUidCalendar ); |
|
1788 |
|
1789 TInt err = KErrNotFound; |
|
1790 |
|
1791 if ( repository ) |
|
1792 { |
|
1793 err = repository->Get( |
|
1794 KCalendarDefaultAlarmTime, |
|
1795 defaultAlarmTime ); |
|
1796 CleanupStack::PopAndDestroy( repository ); |
|
1797 } |
|
1798 |
|
1799 if ( err != KErrNone ) |
|
1800 { |
|
1801 // By default 15 minutes if not found from central repository |
|
1802 defaultAlarmTime = KDefaultMeetingAlarmMinutes; |
|
1803 } |
|
1804 |
|
1805 // Getting current time |
|
1806 TTime currentTime; |
|
1807 currentTime.HomeTime(); |
|
1808 |
|
1809 // Getting meeting start time |
|
1810 TTime start = iEntry->StartTimeL().TimeLocalL(); |
|
1811 |
|
1812 // Create default alarm |
|
1813 CCalAlarm* alarm = CCalAlarm::NewL(); |
|
1814 CleanupStack::PushL( alarm ); |
|
1815 |
|
1816 TTimeIntervalMinutes alarmOffset( defaultAlarmTime ); |
|
1817 |
|
1818 // If alarm time is in past |
|
1819 if ( ( start - alarmOffset ) < currentTime ) |
|
1820 { |
|
1821 // Setting alarm off |
|
1822 iEntry->SetAlarmL( NULL ); |
|
1823 } |
|
1824 else |
|
1825 { |
|
1826 // Set default alarm time |
|
1827 alarm->SetTimeOffset( alarmOffset ); |
|
1828 iEntry->SetAlarmL( alarm ); |
|
1829 } |
|
1830 CleanupStack::PopAndDestroy( alarm ); |
|
1831 } |
|
1832 |
|
1833 // Set the default end time if not set by client |
|
1834 if ( iEntry->StartTimeL().TimeUtcL() == iEntry->EndTimeL().TimeUtcL() ) |
|
1835 { |
|
1836 // This value might also be read from cenrep |
|
1837 TTimeIntervalHours KDefaultMeetingDuration(1); |
|
1838 |
|
1839 TCalTime newEndTime; |
|
1840 newEndTime.SetTimeUtcL( |
|
1841 iEntry->StartTimeL().TimeUtcL() + KDefaultMeetingDuration ); |
|
1842 iEntry->SetStartAndEndTimeL(iEntry->StartTimeL(), newEndTime); |
|
1843 } |
|
1844 |
|
1845 iEntry->SetReplicationStatusL( CCalEntry::EOpen ); |
|
1846 |
|
1847 //Original entry must be stored after the default values are set. |
|
1848 //Otherwise it looks like settings are changed even though they haven't |
|
1849 |
|
1850 CCalEntry* temp = ESMRHelper::CopyEntryL( |
|
1851 *iEntry, |
|
1852 iEntry->MethodL(), |
|
1853 ESMRHelper::ECopyFull ); |
|
1854 |
|
1855 delete iOrginalEntry; |
|
1856 iOrginalEntry = temp; |
|
1857 |
|
1858 } |
|
1859 |
|
1860 |
|
1861 // --------------------------------------------------------------------------- |
|
1862 // CESMRMeetingRequestEntry::IsOpenedFromMail |
|
1863 // --------------------------------------------------------------------------- |
|
1864 // |
|
1865 TBool CESMRMeetingRequestEntry::IsOpenedFromMail() const |
|
1866 { |
|
1867 FUNC_LOG; |
|
1868 TBool openedFromMail( EFalse ); |
|
1869 |
|
1870 if ( iESMRInputParams ) |
|
1871 { |
|
1872 openedFromMail = ETrue; |
|
1873 } |
|
1874 |
|
1875 return openedFromMail; |
|
1876 } |
|
1877 |
|
1878 // --------------------------------------------------------------------------- |
|
1879 // CESMRMeetingRequestEntry::GetAddedAttendeesL |
|
1880 // --------------------------------------------------------------------------- |
|
1881 // |
|
1882 void CESMRMeetingRequestEntry::GetAddedAttendeesL( |
|
1883 RArray<CCalAttendee*>& aAttendeeArray, |
|
1884 TUint aFilterFlags ) const |
|
1885 { |
|
1886 FUNC_LOG; |
|
1887 |
|
1888 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1889 |
|
1890 CESMRCalUserUtil* caluserUtil = CESMRCalUserUtil::NewLC( *iEntry ); |
|
1891 caluserUtil->GetAttendeesL( aAttendeeArray, aFilterFlags ); |
|
1892 CleanupStack::PopAndDestroy( caluserUtil ); |
|
1893 caluserUtil = NULL; |
|
1894 |
|
1895 RArray<CCalAttendee*> orgAttendees; |
|
1896 CleanupClosePushL( orgAttendees ); |
|
1897 |
|
1898 caluserUtil = CESMRCalUserUtil::NewLC( *iParameterEntry ); |
|
1899 caluserUtil->GetAttendeesL( orgAttendees, aFilterFlags ); |
|
1900 |
|
1901 CleanupStack::PopAndDestroy( caluserUtil ); |
|
1902 caluserUtil = NULL; |
|
1903 |
|
1904 TInt index( 0 ); |
|
1905 while( index < aAttendeeArray.Count() ) |
|
1906 { |
|
1907 TPtrC attendeeEmail( aAttendeeArray[index]->Address() ); |
|
1908 |
|
1909 TBool found( EFalse ); |
|
1910 TInt orgAttendeeCount( orgAttendees.Count() ); |
|
1911 for( TInt i(0); (i < orgAttendeeCount) && !found; ++i ) |
|
1912 { |
|
1913 TPtrC orgAttendeeEmail( orgAttendees[i]->Address() ); |
|
1914 if ( 0 == attendeeEmail.CompareF(orgAttendeeEmail) ) |
|
1915 { |
|
1916 found = ETrue; |
|
1917 } |
|
1918 } |
|
1919 |
|
1920 if ( found ) |
|
1921 { |
|
1922 // Attendee was not found from orginal list |
|
1923 // --> it is added |
|
1924 aAttendeeArray.Remove( index ); |
|
1925 } |
|
1926 else |
|
1927 { |
|
1928 ++index; |
|
1929 } |
|
1930 } |
|
1931 |
|
1932 CleanupStack::PopAndDestroy( &orgAttendees ); |
|
1933 |
|
1934 } |
|
1935 |
|
1936 // --------------------------------------------------------------------------- |
|
1937 // CESMRMeetingRequestEntry::GetRemovedAttendeesL |
|
1938 // --------------------------------------------------------------------------- |
|
1939 // |
|
1940 void CESMRMeetingRequestEntry::GetRemovedAttendeesL( |
|
1941 RArray<CCalAttendee*>& aAttendeeArray, |
|
1942 TUint aFilterFlags ) const |
|
1943 { |
|
1944 FUNC_LOG; |
|
1945 |
|
1946 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
1947 |
|
1948 CESMRCalUserUtil* caluserUtil = CESMRCalUserUtil::NewLC( *iParameterEntry ); |
|
1949 caluserUtil->GetAttendeesL( aAttendeeArray, aFilterFlags ); |
|
1950 CleanupStack::PopAndDestroy( caluserUtil ); |
|
1951 caluserUtil = NULL; |
|
1952 |
|
1953 RArray<CCalAttendee*> currentAttendees; |
|
1954 CleanupClosePushL( currentAttendees ); |
|
1955 |
|
1956 caluserUtil = CESMRCalUserUtil::NewLC( *iEntry ); |
|
1957 caluserUtil->GetAttendeesL( currentAttendees, aFilterFlags ); |
|
1958 |
|
1959 CleanupStack::PopAndDestroy( caluserUtil ); |
|
1960 caluserUtil = NULL; |
|
1961 |
|
1962 TInt index( 0 ); |
|
1963 while( index < aAttendeeArray.Count() ) |
|
1964 { |
|
1965 TPtrC attendeeEmail( aAttendeeArray[index]->Address() ); |
|
1966 |
|
1967 TBool found( EFalse ); |
|
1968 TInt orgAttendeeCount( currentAttendees.Count() ); |
|
1969 for( TInt i(0); (i < orgAttendeeCount) && !found; ++i ) |
|
1970 { |
|
1971 TPtrC curAttendeeEmail( currentAttendees[i]->Address() ); |
|
1972 if ( 0 == attendeeEmail.CompareF(curAttendeeEmail) ) |
|
1973 { |
|
1974 found = ETrue; |
|
1975 } |
|
1976 } |
|
1977 |
|
1978 if ( found ) |
|
1979 { |
|
1980 // Attendee was found from orginal list |
|
1981 // --> It has not been removed from MR |
|
1982 aAttendeeArray.Remove( index ); |
|
1983 } |
|
1984 else |
|
1985 { |
|
1986 ++index; |
|
1987 } |
|
1988 } |
|
1989 |
|
1990 CleanupStack::PopAndDestroy( ¤tAttendees ); |
|
1991 |
|
1992 } |
|
1993 |
|
1994 // --------------------------------------------------------------------------- |
|
1995 // CESMRMeetingRequestEntry::UpdateEntryAfterStoringL |
|
1996 // --------------------------------------------------------------------------- |
|
1997 // |
|
1998 void CESMRMeetingRequestEntry::UpdateEntryAfterStoringL() |
|
1999 { |
|
2000 FUNC_LOG; |
|
2001 |
|
2002 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
2003 |
|
2004 CCalEntry* temp = ESMRHelper::CopyEntryL( |
|
2005 *iEntry, |
|
2006 iEntry->MethodL(), |
|
2007 ESMRHelper::ECopyFull ); |
|
2008 |
|
2009 delete iOrginalEntry; |
|
2010 iOrginalEntry = temp; |
|
2011 |
|
2012 } |
|
2013 |
|
2014 // --------------------------------------------------------------------------- |
|
2015 // CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL |
|
2016 // --------------------------------------------------------------------------- |
|
2017 // |
|
2018 void CESMRMeetingRequestEntry::UpdateChildEntriesSeqNumbersL() |
|
2019 { |
|
2020 FUNC_LOG; |
|
2021 |
|
2022 if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule && |
|
2023 IsStoredL() ) |
|
2024 { |
|
2025 RCPointerArray<CCalEntry> childEntries; |
|
2026 CleanupClosePushL( childEntries ); |
|
2027 |
|
2028 // Fetch all entries (this and child entries |
|
2029 iCalDb.NormalDbEntryView()->FetchL( |
|
2030 iEntry->UidL(), |
|
2031 childEntries ); |
|
2032 |
|
2033 // Next: Remove parent entry from the array |
|
2034 TBool removed( EFalse ); |
|
2035 TInt entryCount( childEntries.Count() ); |
|
2036 for ( TInt i(0); (i < entryCount) && !removed; ++i ) |
|
2037 { |
|
2038 CCalEntry* entry = childEntries[i]; |
|
2039 |
|
2040 if ( !ESMREntryHelper::IsModifyingEntryL( *entry) ) |
|
2041 { |
|
2042 removed = ETrue; |
|
2043 childEntries.Remove( i ); |
|
2044 delete entry; |
|
2045 } |
|
2046 entry = NULL; |
|
2047 } |
|
2048 |
|
2049 TInt childCount( childEntries.Count() ); |
|
2050 if ( childCount ) |
|
2051 { |
|
2052 for (TInt i(0); i < childCount; ++i ) |
|
2053 { |
|
2054 CCalEntry* child = childEntries[i]; |
|
2055 TInt childSeqNo( child->SequenceNumberL() ); |
|
2056 child->SetSequenceNumberL( childSeqNo + 1); |
|
2057 } |
|
2058 |
|
2059 TInt updatedChilds; |
|
2060 iCalDb.NormalDbEntryView()->StoreL(childEntries, updatedChilds); |
|
2061 } |
|
2062 |
|
2063 CleanupStack::PopAndDestroy(); // childEntries |
|
2064 } |
|
2065 |
|
2066 } |
|
2067 |
|
2068 // --------------------------------------------------------------------------- |
|
2069 // CESMRMeetingRequestEntry::CurrentPluginL |
|
2070 // --------------------------------------------------------------------------- |
|
2071 // |
|
2072 TESMRMailPlugin CESMRMeetingRequestEntry::CurrentPluginL() |
|
2073 { |
|
2074 FUNC_LOG; |
|
2075 |
|
2076 if ( EESMRUnknownPlugin == iCurrentFSEmailPlugin) |
|
2077 { |
|
2078 CESMRFsMailboxUtils* fsMbUtils = |
|
2079 CESMRFsMailboxUtils::NewL( iMRMailboxUtils ); |
|
2080 CleanupStack::PushL( fsMbUtils ); |
|
2081 |
|
2082 iCurrentFSEmailPlugin = fsMbUtils->FSEmailPluginForEntryL( *iEntry ); |
|
2083 CleanupStack::PopAndDestroy( fsMbUtils ); |
|
2084 fsMbUtils = NULL; |
|
2085 } |
|
2086 |
|
2087 |
|
2088 return iCurrentFSEmailPlugin; |
|
2089 } |
|
2090 |
|
2091 // --------------------------------------------------------------------------- |
|
2092 // CESMRMeetingRequestEntry::CurrentMailBoxIdL |
|
2093 // --------------------------------------------------------------------------- |
|
2094 // |
|
2095 TFSMailMsgId CESMRMeetingRequestEntry::CurrentMailBoxIdL() |
|
2096 { |
|
2097 FUNC_LOG; |
|
2098 CESMRFsMailboxUtils* fsMbUtils = |
|
2099 CESMRFsMailboxUtils::NewL( iMRMailboxUtils ); |
|
2100 CleanupStack::PushL( fsMbUtils ); |
|
2101 TFSMailMsgId retVal = fsMbUtils->FSEmailMailBoxForEntryL( *iEntry ); |
|
2102 CleanupStack::PopAndDestroy( fsMbUtils ); |
|
2103 return retVal; |
|
2104 } |
|
2105 |
|
2106 // --------------------------------------------------------------------------- |
|
2107 // CESMRMeetingRequestEntry::UpdateTimeStampL |
|
2108 // --------------------------------------------------------------------------- |
|
2109 // |
|
2110 void CESMRMeetingRequestEntry::UpdateTimeStampL() |
|
2111 { |
|
2112 FUNC_LOG; |
|
2113 __ASSERT_DEBUG( iEntry, Panic(EESMREntryNotExist ) ); |
|
2114 |
|
2115 TTime currentUTCTime; |
|
2116 currentUTCTime.UniversalTime(); |
|
2117 |
|
2118 TCalTime currentTime; |
|
2119 currentTime.SetTimeUtcL( currentUTCTime ); |
|
2120 |
|
2121 iEntry->SetDTStampL( currentTime ); |
|
2122 } |
|
2123 |
|
2124 // --------------------------------------------------------------------------- |
|
2125 // CESMRMeetingRequestEntry::UpdateTimeStampL |
|
2126 // --------------------------------------------------------------------------- |
|
2127 // |
|
2128 TBool CESMRMeetingRequestEntry::AnyInstanceOnDayL( |
|
2129 TTime& aStart, |
|
2130 TTime& aEnd ) |
|
2131 { |
|
2132 FUNC_LOG; |
|
2133 TBool retValue( EFalse ); |
|
2134 |
|
2135 RCPointerArray<CCalEntry> entries; |
|
2136 CleanupClosePushL( entries ); |
|
2137 |
|
2138 CESMRConflictChecker* conflictCheckker = |
|
2139 CESMRConflictChecker::NewL( iCalDb ); |
|
2140 CleanupStack::PushL( conflictCheckker ); |
|
2141 |
|
2142 conflictCheckker->FindInstancesForEntryL( aStart, |
|
2143 aEnd, |
|
2144 *iEntry, |
|
2145 entries ); |
|
2146 |
|
2147 if ( entries.Count() ) |
|
2148 { |
|
2149 retValue = ETrue; |
|
2150 } |
|
2151 |
|
2152 CleanupStack::PopAndDestroy( conflictCheckker ); |
|
2153 CleanupStack::PopAndDestroy(); // entries |
|
2154 |
|
2155 return retValue; |
|
2156 } |
|
2157 |
|
2158 // EOF |
|
2159 |