|
1 /* |
|
2 * Copyright (c) 2006 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: CalenEntryUtil stores data from edited Symbian CCalEntry |
|
15 * to format that match Calendar Editors fields. Editor fields |
|
16 * update CalenEntryUtil. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 //debug |
|
23 #include "calendarui_debug.h" |
|
24 |
|
25 #include "calenentryutil.h" |
|
26 |
|
27 #include <calendateutils.h> |
|
28 |
|
29 #include <calalarm.h> |
|
30 #include <calentry.h> |
|
31 #include <calrrule.h> |
|
32 #include <calattachment.h> |
|
33 |
|
34 |
|
35 // Utility functions |
|
36 |
|
37 // ======== LOCAL FUNCTIONS ======== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // ThrowAwaySecondsAndMicroSecondsL |
|
41 // Remove the seconds and micro seconds part from a TTime. |
|
42 // (other items were commented in a header). |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 static TTime ThrowAwaySecondsAndMicroSecondsL( const TTime& aTime ) |
|
46 { |
|
47 TRACE_ENTRY_POINT; |
|
48 |
|
49 TDateTime dt = aTime.DateTime(); |
|
50 dt.SetSecond(0); |
|
51 dt.SetMicroSecond(0); |
|
52 TTime result( dt ); |
|
53 |
|
54 TRACE_EXIT_POINT; |
|
55 return result; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // DurationL |
|
60 // Returns the difference between the start and end time of an entry. |
|
61 // (other items were commented in a header). |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 static TTimeIntervalMinutes DurationL( const CCalEntry& aEntry ) |
|
65 { |
|
66 TRACE_ENTRY_POINT; |
|
67 |
|
68 TTimeIntervalMinutes duration; |
|
69 |
|
70 TTime start = aEntry.StartTimeL().TimeLocalL(); |
|
71 TTime end = aEntry.EndTimeL().TimeLocalL(); |
|
72 end.MinutesFrom( start, duration ); |
|
73 |
|
74 TRACE_EXIT_POINT; |
|
75 return duration; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // StoreDescriptorL |
|
80 // Gets reference to target HBufC& and attempts to copy data to it. |
|
81 // (other items were commented in a header). |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 static void StoreDescriptorL(const TDesC& aSrc, HBufC*& aTgt) |
|
85 { |
|
86 TRACE_ENTRY_POINT; |
|
87 |
|
88 // Simplistic implementation |
|
89 delete aTgt; // it's safe to delete null pointers |
|
90 aTgt = NULL; |
|
91 aTgt = aSrc.AllocL(); |
|
92 // Complex and more efficient implementation |
|
93 // if ( aSrc.Length() <= aTgt->Des().MaxLength() ) |
|
94 // { |
|
95 // aTgt->Des().Copy( aSrc ); |
|
96 // } |
|
97 // else |
|
98 // { |
|
99 // delete aTgt; |
|
100 // aTgt = NULL; |
|
101 // aTgt = aSrc.AllocL(); |
|
102 // } |
|
103 |
|
104 TRACE_EXIT_POINT; |
|
105 } |
|
106 |
|
107 // ======== MEMBER FUNCTIONS ======== |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CCalenEntryUtil::NewL |
|
111 // Two-phased constructor. |
|
112 // (other items were commented in a header). |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C CCalenEntryUtil* CCalenEntryUtil::NewL(CCalEntry& aEntry, |
|
116 const TCalTime& aInstanceDateTime ) |
|
117 { |
|
118 TRACE_ENTRY_POINT; |
|
119 |
|
120 CCalenEntryUtil* self = new (ELeave) CCalenEntryUtil(aEntry); |
|
121 CleanupStack::PushL( self ); |
|
122 self->ConstructL(aEntry, aInstanceDateTime); |
|
123 CleanupStack::Pop( self ); |
|
124 |
|
125 TRACE_EXIT_POINT; |
|
126 return self; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CCalenEntryUtil::~CCalenEntryUtil |
|
131 // Destructor. |
|
132 // (other items were commented in a header). |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 CCalenEntryUtil::~CCalenEntryUtil() |
|
136 { |
|
137 TRACE_ENTRY_POINT; |
|
138 |
|
139 delete iSummary; |
|
140 delete iLocation; |
|
141 delete iDescription; |
|
142 |
|
143 TRACE_EXIT_POINT; |
|
144 } |
|
145 |
|
146 // Getters |
|
147 EXPORT_C const CCalEntry::TType& CCalenEntryUtil::EntryType() const |
|
148 { |
|
149 TRACE_ENTRY_POINT; |
|
150 |
|
151 TRACE_EXIT_POINT; |
|
152 return iEntryType; |
|
153 } |
|
154 |
|
155 EXPORT_C const CCalEntry::TStatus& CCalenEntryUtil::Status() const |
|
156 { |
|
157 TRACE_ENTRY_POINT; |
|
158 |
|
159 TRACE_EXIT_POINT; |
|
160 return iEntryStatus; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CCalenEntryUtil::Summary |
|
165 // Returns the summary. |
|
166 // (other items were commented in a header). |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 EXPORT_C const TDesC& CCalenEntryUtil::Summary() const |
|
170 { |
|
171 TRACE_ENTRY_POINT; |
|
172 |
|
173 ASSERT( iSummary ); |
|
174 |
|
175 TRACE_EXIT_POINT; |
|
176 return *iSummary; |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CCalenEntryUtil::Location |
|
181 // Returns the location. |
|
182 // (other items were commented in a header). |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 EXPORT_C const TDesC& CCalenEntryUtil::Location() const |
|
186 { |
|
187 TRACE_ENTRY_POINT; |
|
188 |
|
189 ASSERT( iLocation ); |
|
190 |
|
191 TRACE_EXIT_POINT; |
|
192 return *iLocation; |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CCalenEntryUtil::Description |
|
197 // Returns the description. |
|
198 // (other items were commented in a header). |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 EXPORT_C const TDesC& CCalenEntryUtil::Description() const |
|
202 { |
|
203 TRACE_ENTRY_POINT; |
|
204 |
|
205 ASSERT( iDescription ); |
|
206 |
|
207 TRACE_EXIT_POINT; |
|
208 return *iDescription; |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CCalenEntryUtil::StartDateTime |
|
213 // Returns the start date time. |
|
214 // (other items were commented in a header). |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 EXPORT_C const TTime& CCalenEntryUtil::StartDateTime() const |
|
218 { |
|
219 TRACE_ENTRY_POINT; |
|
220 |
|
221 TRACE_EXIT_POINT; |
|
222 return iStartDateTime; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CCalenEntryUtil::EndDateTime |
|
227 // Returns the end date time. |
|
228 // (other items were commented in a header). |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 EXPORT_C const TTime& CCalenEntryUtil::EndDateTime() const |
|
232 { |
|
233 TRACE_ENTRY_POINT; |
|
234 |
|
235 TRACE_EXIT_POINT; |
|
236 return iEndDateTime; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CCalenEntryUtil::EventDateTime |
|
241 // Returns the event date time. |
|
242 // (other items were commented in a header). |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 EXPORT_C const TTime& CCalenEntryUtil::EventDateTime() const |
|
246 { |
|
247 TRACE_ENTRY_POINT; |
|
248 |
|
249 TRACE_EXIT_POINT; |
|
250 return StartDateTime(); |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CCalenEntryUtil::IsAlarmActivated |
|
255 // Returns ETrue if the alarm is activated, EFalse otherwise. |
|
256 // (other items were commented in a header). |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 EXPORT_C TBool CCalenEntryUtil::IsAlarmActivated() const |
|
260 { |
|
261 TRACE_ENTRY_POINT; |
|
262 |
|
263 TRACE_EXIT_POINT; |
|
264 return iIsAlarmActivated; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CCalenEntryUtil::IsAllDayEvent |
|
269 // Returns ETrue if meeting is AllDay event, EFalse otherwise. |
|
270 // (other items were commented in a header). |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C TBool CCalenEntryUtil::IsAllDayEvent() |
|
274 { |
|
275 TRACE_ENTRY_POINT; |
|
276 |
|
277 TRACE_EXIT_POINT; |
|
278 return iIsAllDayEvent; |
|
279 } |
|
280 |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CCalenEntryUtil::AlarmDateTime |
|
284 // Returns the alarm date time. |
|
285 // (other items were commented in a header). |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 EXPORT_C const TTime& CCalenEntryUtil::AlarmDateTime() const |
|
289 { |
|
290 TRACE_ENTRY_POINT; |
|
291 |
|
292 ASSERT( iIsAlarmActivated ); |
|
293 |
|
294 TRACE_EXIT_POINT; |
|
295 return iAlarmDateTime; |
|
296 } |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // CCalenEntryUtil::RepeatType |
|
300 // Returns the repeat type. |
|
301 // (other items were commented in a header). |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 EXPORT_C TCalenRepeatIndex CCalenEntryUtil::RepeatType() const |
|
305 { |
|
306 TRACE_ENTRY_POINT; |
|
307 |
|
308 TRACE_EXIT_POINT; |
|
309 return iRepeatType; |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // CCalenEntryUtil::RepeatUntilDateTime |
|
314 // Returns the date/time until which this entry repeats. |
|
315 // (other items were commented in a header). |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 EXPORT_C const TTime& CCalenEntryUtil::RepeatUntilDateTime() const |
|
319 { |
|
320 TRACE_ENTRY_POINT; |
|
321 |
|
322 ASSERT( IsRepeating() ); |
|
323 |
|
324 TRACE_EXIT_POINT; |
|
325 return iRepeatUntilDateTime; |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CCalenEntryUtil::Priority |
|
330 // Returns the priority. |
|
331 // (other items were commented in a header). |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 EXPORT_C CCalenEntryUtil::TTodoPriority CCalenEntryUtil::Priority() const |
|
335 { |
|
336 TRACE_ENTRY_POINT; |
|
337 |
|
338 TRACE_EXIT_POINT; |
|
339 return iPriority; |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CCalenEntryUtil::SynchType |
|
344 // Returns the synchronisation type. |
|
345 // (other items were commented in a header). |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 EXPORT_C CCalenEntryUtil::TSynchType CCalenEntryUtil::SynchType() const |
|
349 { |
|
350 TRACE_ENTRY_POINT; |
|
351 |
|
352 TRACE_EXIT_POINT; |
|
353 return iSynchType; |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CCalenEntryUtil::AttachmentCount |
|
358 // Returns the attachment's count |
|
359 // (other items were commented in a header). |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 EXPORT_C TInt CCalenEntryUtil::AttachmentCount() const |
|
363 { |
|
364 TRACE_ENTRY_POINT; |
|
365 TRACE_EXIT_POINT; |
|
366 return iAttachmentCount; |
|
367 } |
|
368 |
|
369 // Setters |
|
370 |
|
371 // ----------------------------------------------------------------------------- |
|
372 // CCalenEntryUtil::SetSummaryL |
|
373 // Sets the summary. |
|
374 // (other items were commented in a header). |
|
375 // ----------------------------------------------------------------------------- |
|
376 // |
|
377 EXPORT_C void CCalenEntryUtil::SetSummaryL( const TDesC& aSummary ) |
|
378 { |
|
379 TRACE_ENTRY_POINT; |
|
380 |
|
381 StoreDescriptorL( aSummary, iSummary ); |
|
382 |
|
383 TRACE_EXIT_POINT; |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // CCalenEntryUtil::SetLocationL |
|
388 // Sets the location. |
|
389 // (other items were commented in a header). |
|
390 // ----------------------------------------------------------------------------- |
|
391 // |
|
392 EXPORT_C void CCalenEntryUtil::SetLocationL( const TDesC& aLocation ) |
|
393 { |
|
394 TRACE_ENTRY_POINT; |
|
395 |
|
396 StoreDescriptorL( aLocation, iLocation ); |
|
397 |
|
398 TRACE_EXIT_POINT; |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CCalenEntryUtil::SetDescriptionL |
|
403 // Sets the description. |
|
404 // (other items were commented in a header). |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 EXPORT_C void CCalenEntryUtil::SetDescriptionL( const TDesC& aDescription ) |
|
408 { |
|
409 TRACE_ENTRY_POINT; |
|
410 |
|
411 StoreDescriptorL( aDescription, iDescription ); |
|
412 |
|
413 TRACE_EXIT_POINT; |
|
414 } |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CCalenEntryUtil::SetDescriptionTransferOwnershipL |
|
418 // Sets the description, passing ownership of aDescription. |
|
419 // (other items were commented in a header). |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 EXPORT_C void CCalenEntryUtil::SetDescriptionTransferOwnershipL( HBufC* aDescription ) |
|
423 { |
|
424 TRACE_ENTRY_POINT; |
|
425 |
|
426 delete iDescription; |
|
427 iDescription = aDescription; |
|
428 |
|
429 TRACE_EXIT_POINT; |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // CCalenEntryUtil::SetStartDateTimeL |
|
434 // Sets the start date/time. |
|
435 // (other items were commented in a header). |
|
436 // ----------------------------------------------------------------------------- |
|
437 // |
|
438 EXPORT_C void CCalenEntryUtil::SetStartDateTimeL( const TTime& aStart ) |
|
439 { |
|
440 TRACE_ENTRY_POINT; |
|
441 |
|
442 iStartDateTime = ThrowAwaySecondsAndMicroSecondsL( aStart ); |
|
443 |
|
444 TRACE_EXIT_POINT; |
|
445 } |
|
446 |
|
447 // ----------------------------------------------------------------------------- |
|
448 // CCalenEntryUtil::SetEndDateTimeL |
|
449 // Sets the end date/time. |
|
450 // (other items were commented in a header). |
|
451 // ----------------------------------------------------------------------------- |
|
452 // |
|
453 EXPORT_C void CCalenEntryUtil::SetEndDateTimeL( const TTime& aEnd ) |
|
454 { |
|
455 TRACE_ENTRY_POINT; |
|
456 |
|
457 iEndDateTime = ThrowAwaySecondsAndMicroSecondsL( aEnd ); |
|
458 |
|
459 TRACE_EXIT_POINT; |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CCalenEntryUtil::SetEventDateL |
|
464 // Sets the event date. |
|
465 // (other items were commented in a header). |
|
466 // ----------------------------------------------------------------------------- |
|
467 // |
|
468 EXPORT_C void CCalenEntryUtil::SetEventDateL( const TTime& aDate) |
|
469 { |
|
470 TRACE_ENTRY_POINT; |
|
471 |
|
472 TTime midnight = CalenDateUtils::BeginningOfDay( aDate ); |
|
473 SetStartDateTimeL( midnight ); |
|
474 SetEndDateTimeL( midnight ); |
|
475 |
|
476 TRACE_EXIT_POINT; |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CCalenEntryUtil::SetAlarmOnL |
|
481 // Sets the alarm to be active at the given date/time. |
|
482 // (other items were commented in a header). |
|
483 // ----------------------------------------------------------------------------- |
|
484 // |
|
485 EXPORT_C void CCalenEntryUtil::SetAlarmOnL( const TTime& aAlarmTime ) |
|
486 { |
|
487 TRACE_ENTRY_POINT; |
|
488 |
|
489 iIsAlarmActivated = ETrue; |
|
490 iAlarmDateTime = ThrowAwaySecondsAndMicroSecondsL( aAlarmTime ); |
|
491 |
|
492 TRACE_EXIT_POINT; |
|
493 } |
|
494 |
|
495 // ----------------------------------------------------------------------------- |
|
496 // CCalenEntryUtil::SetAlarmOffL |
|
497 // Turns off the alarm. |
|
498 // (other items were commented in a header). |
|
499 // ----------------------------------------------------------------------------- |
|
500 // |
|
501 EXPORT_C void CCalenEntryUtil::SetAlarmOffL() |
|
502 { |
|
503 TRACE_ENTRY_POINT; |
|
504 |
|
505 iIsAlarmActivated = EFalse; |
|
506 iAlarmDateTime = Time::NullTTime(); |
|
507 |
|
508 TRACE_EXIT_POINT; |
|
509 } |
|
510 |
|
511 // ----------------------------------------------------------------------------- |
|
512 // CCalenEntryUtil::SetAlarmDateTimeL |
|
513 // Sets the alarm to be at the given time. Note that you must call SetAlarmOnL() |
|
514 // before calling this function. |
|
515 // (other items were commented in a header). |
|
516 // ----------------------------------------------------------------------------- |
|
517 // |
|
518 EXPORT_C void CCalenEntryUtil::SetAlarmDateTimeL( const TTime& aTime ) |
|
519 { |
|
520 TRACE_ENTRY_POINT; |
|
521 |
|
522 __ASSERT_ALWAYS( iIsAlarmActivated, User::Leave( KErrNotReady ) ); |
|
523 iAlarmDateTime = ThrowAwaySecondsAndMicroSecondsL( aTime ); |
|
524 |
|
525 TRACE_EXIT_POINT; |
|
526 } |
|
527 |
|
528 // ----------------------------------------------------------------------------- |
|
529 // CCalenEntryUtil::SetNonRepeatingL |
|
530 // Sets the event to be non-repeating. |
|
531 // (other items were commented in a header). |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 EXPORT_C void CCalenEntryUtil::SetNonRepeatingL() |
|
535 { |
|
536 TRACE_ENTRY_POINT; |
|
537 |
|
538 iRepeatType = ERepeatNotRepeated; |
|
539 iRepeatUntilDateTime = Time::NullTTime(); |
|
540 |
|
541 TRACE_EXIT_POINT; |
|
542 } |
|
543 |
|
544 // ----------------------------------------------------------------------------- |
|
545 // CCalenEntryUtil::SetRepeatingL |
|
546 // Sets the event to be repeating, based on repeat type and until date/time |
|
547 // passed in. |
|
548 // (other items were commented in a header). |
|
549 // ----------------------------------------------------------------------------- |
|
550 // |
|
551 EXPORT_C void CCalenEntryUtil::SetRepeatingL(TCalenRepeatIndex aRepeatType, const TTime& aUntilDateTime ) |
|
552 { |
|
553 TRACE_ENTRY_POINT; |
|
554 |
|
555 iRepeatType = aRepeatType; |
|
556 iRepeatUntilDateTime = CalenDateUtils::LimitToValidTime( |
|
557 CalenDateUtils::BeginningOfDay( aUntilDateTime )); |
|
558 |
|
559 |
|
560 TRACE_EXIT_POINT; |
|
561 } |
|
562 |
|
563 // ----------------------------------------------------------------------------- |
|
564 // CCalenEntryUtil::SetRepeatUntilDateTimeL |
|
565 // Sets the event to repeat until the given date/time. Note that you must call |
|
566 // SetRepeatingL before calling this function. |
|
567 // (other items were commented in a header). |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 EXPORT_C void CCalenEntryUtil::SetRepeatUntilDateTimeL(const TTime& aTime) |
|
571 { |
|
572 TRACE_ENTRY_POINT; |
|
573 |
|
574 __ASSERT_ALWAYS( IsRepeating(), User::Leave( KErrNotReady ) ); |
|
575 SetRepeatingL( iRepeatType, aTime ); |
|
576 |
|
577 TRACE_EXIT_POINT; |
|
578 } |
|
579 |
|
580 // ----------------------------------------------------------------------------- |
|
581 // CCalenEntryUtil::SetPriorityL |
|
582 // Sets the priority. |
|
583 // (other items were commented in a header). |
|
584 // ----------------------------------------------------------------------------- |
|
585 // |
|
586 EXPORT_C void CCalenEntryUtil::SetPriorityL(CCalenEntryUtil::TTodoPriority aPriority) |
|
587 { |
|
588 TRACE_ENTRY_POINT; |
|
589 |
|
590 iPriority = aPriority; |
|
591 |
|
592 TRACE_EXIT_POINT; |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // CCalenEntryUtil::SetSynchTypeL |
|
597 // Sets the sychronisation type. |
|
598 // (other items were commented in a header). |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 EXPORT_C void CCalenEntryUtil::SetSynchTypeL(CCalenEntryUtil::TSynchType aSynchType) |
|
602 { |
|
603 TRACE_ENTRY_POINT; |
|
604 |
|
605 iSynchType = aSynchType; |
|
606 |
|
607 TRACE_EXIT_POINT; |
|
608 } |
|
609 |
|
610 // ----------------------------------------------------------------------------- |
|
611 // CCalenEntryUtil::SetEntryType |
|
612 // Sets the unsigned user int. |
|
613 // (other items were commented in a header). |
|
614 // ----------------------------------------------------------------------------- |
|
615 // |
|
616 EXPORT_C void CCalenEntryUtil::SetEntryType( CCalEntry::TType aEntryType ) |
|
617 { |
|
618 TRACE_ENTRY_POINT; |
|
619 |
|
620 iEntryType = aEntryType; |
|
621 |
|
622 TRACE_EXIT_POINT; |
|
623 |
|
624 } |
|
625 // ----------------------------------------------------------------------------- |
|
626 // CCalenEntryUtil::SetUserIntL |
|
627 // Sets the attachments count |
|
628 // (other items were commented in a header). |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 EXPORT_C void CCalenEntryUtil::SetAttachmentCount(TInt aAttachmentCount) |
|
632 { |
|
633 TRACE_ENTRY_POINT; |
|
634 |
|
635 iAttachmentCount = aAttachmentCount; |
|
636 |
|
637 TRACE_EXIT_POINT; |
|
638 } |
|
639 |
|
640 // ----------------------------------------------------------------------------- |
|
641 // CCalenEntryUtil::SetAllDayEvent |
|
642 // Sets the unsigned user int. |
|
643 // (other items were commented in a header). |
|
644 // ----------------------------------------------------------------------------- |
|
645 // |
|
646 EXPORT_C void CCalenEntryUtil::SetAllDayEvent(TBool aAllDayEvent ) |
|
647 { |
|
648 TRACE_ENTRY_POINT; |
|
649 |
|
650 iIsAllDayEvent = aAllDayEvent; |
|
651 |
|
652 TRACE_EXIT_POINT; |
|
653 } |
|
654 // Utility functions |
|
655 |
|
656 // ----------------------------------------------------------------------------- |
|
657 // CCalenEntryUtil::IsRepeating |
|
658 // Returns ETrue if the entry is repeating, EFalse otherwise. |
|
659 // (other items were commented in a header). |
|
660 // ----------------------------------------------------------------------------- |
|
661 // |
|
662 EXPORT_C TBool CCalenEntryUtil::IsRepeating() const |
|
663 { |
|
664 TRACE_ENTRY_POINT; |
|
665 |
|
666 TRACE_EXIT_POINT; |
|
667 return iRepeatType != ERepeatNotRepeated; |
|
668 } |
|
669 |
|
670 // Private functions |
|
671 |
|
672 // ----------------------------------------------------------------------------- |
|
673 // CCalenEntryUtil::CCalenEntryUtil |
|
674 // Constructor. |
|
675 // (other items were commented in a header). |
|
676 // ----------------------------------------------------------------------------- |
|
677 // |
|
678 CCalenEntryUtil::CCalenEntryUtil(CCalEntry& aEntry) |
|
679 : iEntry(aEntry),iAttachmentCount(0) |
|
680 { |
|
681 TRACE_ENTRY_POINT; |
|
682 TRACE_EXIT_POINT; |
|
683 } |
|
684 |
|
685 // ----------------------------------------------------------------------------- |
|
686 // CCalenEntryUtil::ConstructL |
|
687 // Leaving construction. |
|
688 // (other items were commented in a header). |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 void CCalenEntryUtil::ConstructL( CCalEntry& aEntry, |
|
692 const TCalTime& aInstanceDateTime ) |
|
693 { |
|
694 TRACE_ENTRY_POINT; |
|
695 iEntryType = aEntry.EntryTypeL(); |
|
696 iEntryStatus = aEntry.StatusL(); |
|
697 CopyDataFromEntryL( aEntry, aInstanceDateTime ); |
|
698 |
|
699 TRACE_EXIT_POINT; |
|
700 } |
|
701 |
|
702 // ----------------------------------------------------------------------------- |
|
703 // CCalenEntryUtil::CopyDataFromEntryL |
|
704 // Copy data from the given entry to this class. |
|
705 // (other items were commented in a header). |
|
706 // ----------------------------------------------------------------------------- |
|
707 // |
|
708 void CCalenEntryUtil::CopyDataFromEntryL( CCalEntry& aEntry, const TCalTime& aInstanceDateTime ) |
|
709 { |
|
710 TRACE_ENTRY_POINT; |
|
711 |
|
712 SetSummaryL( aEntry.SummaryL() ); |
|
713 SetLocationL( aEntry.LocationL() ); |
|
714 SetDescriptionL( aEntry.DescriptionL() ); |
|
715 |
|
716 switch ( aEntry.EntryTypeL() ) |
|
717 { |
|
718 case CCalEntry::EAppt: |
|
719 { |
|
720 TTime start = aInstanceDateTime.TimeLocalL(); |
|
721 TTime end = start + DurationL( aEntry ); |
|
722 SetStartDateTimeL( start ); |
|
723 SetEndDateTimeL( end ); |
|
724 |
|
725 // Appt. is AllDay Event |
|
726 SetAllDayEvent( CheckForAlldayEventL( start,end ) ); |
|
727 } |
|
728 break; |
|
729 |
|
730 case CCalEntry::EReminder: |
|
731 { |
|
732 TTime start = aInstanceDateTime.TimeLocalL(); |
|
733 TTime end = start; |
|
734 SetStartDateTimeL( start ); |
|
735 SetEndDateTimeL( end ); |
|
736 } |
|
737 break; |
|
738 |
|
739 case CCalEntry::EEvent: |
|
740 { |
|
741 // similar to reminder |
|
742 TTime start = aInstanceDateTime.TimeLocalL(); |
|
743 TTime end = start + DurationL( aEntry ); |
|
744 SetStartDateTimeL( start ); |
|
745 SetEndDateTimeL( end ); |
|
746 // event. is AllDay Event |
|
747 SetAllDayEvent( CheckForAlldayEventL( start,end ) ); |
|
748 } |
|
749 break; |
|
750 |
|
751 case CCalEntry::EAnniv: |
|
752 { |
|
753 TTime event = aInstanceDateTime.TimeLocalL(); |
|
754 SetEventDateL( event ); |
|
755 } |
|
756 break; |
|
757 |
|
758 case CCalEntry::ETodo: |
|
759 { |
|
760 // Undated todos |
|
761 TTime dueDate = aEntry.EndTimeL().TimeLocalL(); |
|
762 if ( dueDate == Time::NullTTime() ) |
|
763 { |
|
764 TTime today; |
|
765 today.HomeTime(); |
|
766 today = CalenDateUtils::BeginningOfDay( today ); |
|
767 dueDate = today; |
|
768 } |
|
769 SetEventDateL( dueDate ); |
|
770 } |
|
771 break; |
|
772 |
|
773 default: |
|
774 ASSERT( EFalse ); |
|
775 break; |
|
776 } |
|
777 |
|
778 |
|
779 // Repeat rule |
|
780 TCalRRule rrule; |
|
781 TBool isRepeating = aEntry.GetRRuleL( rrule ); |
|
782 |
|
783 RArray<TCalTime> rdates; |
|
784 CleanupClosePushL( rdates ); |
|
785 aEntry.GetRDatesL( rdates ); |
|
786 TInt count = rdates.Count(); |
|
787 TBool hasRDates = ( count > 0 ); |
|
788 TTime firstRDate; |
|
789 |
|
790 // Get the firstRDate only if the entry has RDates. |
|
791 if( hasRDates ) |
|
792 { |
|
793 firstRDate = rdates[ 0 ].TimeLocalL(); |
|
794 } |
|
795 |
|
796 // If the entry has rdates and/or got rrules, |
|
797 // need to find and set the repeat until date |
|
798 if ( hasRDates || isRepeating ) |
|
799 { |
|
800 TTime repeatUntil = aEntry.StartTimeL().TimeLocalL(); |
|
801 |
|
802 if ( isRepeating ) |
|
803 { |
|
804 // If the entry is repeating find the rrule |
|
805 // repeat until time. |
|
806 TTime rruleUntil = rrule.Until().TimeLocalL(); |
|
807 if ( rruleUntil > repeatUntil ) |
|
808 { |
|
809 repeatUntil = rruleUntil; |
|
810 } |
|
811 } |
|
812 |
|
813 if ( hasRDates ) |
|
814 { |
|
815 // Find the last rdate date, using the fact that |
|
816 // the rdates are sorted in date order |
|
817 TTime lastRDate = rdates [ rdates.Count() - 1 ].TimeLocalL(); |
|
818 |
|
819 // Compare the date of the last rdate with |
|
820 // the current repat until time. |
|
821 if ( lastRDate > repeatUntil ) |
|
822 { |
|
823 repeatUntil = lastRDate; |
|
824 } |
|
825 |
|
826 // Set the repeat type as other. |
|
827 SetRepeatingL( ERepeatOther, repeatUntil ); |
|
828 |
|
829 // If the first rDate is before the start of any rRule, |
|
830 // the first rDate will have to be disguised as |
|
831 // the start of the series |
|
832 if ( firstRDate <= StartDateTime() ) |
|
833 { |
|
834 // Only if I am editing the ENTRY, i need the first instance date. |
|
835 // Also if the entry has an RDate before the first instance date, |
|
836 // make the StartDay as the first RDate. |
|
837 if( iRecurrenceType == CalCommon::EThisAndAll ) |
|
838 { |
|
839 TTimeIntervalMinutes duration; |
|
840 |
|
841 User::LeaveIfError( EndDateTime().MinutesFrom( StartDateTime(), duration ) ); |
|
842 SetStartDateTimeL( firstRDate ); |
|
843 TTime endDate = firstRDate + duration; |
|
844 SetEndDateTimeL( endDate ); |
|
845 } |
|
846 } |
|
847 } |
|
848 else |
|
849 { |
|
850 // Find the repeat type and set the repeat type. |
|
851 TCalenRepeatIndex repeatType = CalenNoteDataUtil::RepeatIndexL( aEntry ); |
|
852 ASSERT( repeatType != ERepeatNotRepeated ); |
|
853 |
|
854 SetRepeatingL( repeatType, repeatUntil ); |
|
855 } |
|
856 } |
|
857 else |
|
858 { |
|
859 SetNonRepeatingL(); |
|
860 } |
|
861 |
|
862 // Alarm |
|
863 TTime alarmDateTime; |
|
864 TBool hasAlarm = CalenNoteDataUtil::GetAlarmDateTimeL( aEntry, |
|
865 alarmDateTime ); |
|
866 |
|
867 if ( hasAlarm ) |
|
868 { |
|
869 TTimeIntervalDays deltaDays; |
|
870 TTimeIntervalDays alarmOffset = alarmDateTime.DaysFrom( aEntry.StartTimeL().TimeLocalL() ); |
|
871 TTimeIntervalDays alarmDeltaDays; |
|
872 TTimeIntervalDays instanceDeltaDays; |
|
873 |
|
874 // alarm time should be offset from instance date, not entry date. |
|
875 // As instance date time might have different time of day (repeating entries defined by RDATEs) |
|
876 // than entry start, we need to nudge only days to instance date, and keep time of alarm same. |
|
877 if ( isRepeating ) |
|
878 { |
|
879 if( hasRDates ) |
|
880 { |
|
881 if( (CalCommon::EThisAndAll == iRecurrenceType) && (firstRDate <= ( aEntry.StartTimeL().TimeLocalL()) ) ) |
|
882 { |
|
883 // User editing the series and there are RDates and the firstRDate is less than the |
|
884 // entry start date, the alarmtime for the first entry date (firstRDate) is just the |
|
885 // offset. |
|
886 instanceDeltaDays = firstRDate.DaysFrom( aEntry.StartTimeL().TimeLocalL() ); |
|
887 deltaDays = instanceDeltaDays; |
|
888 alarmDateTime += deltaDays; |
|
889 } |
|
890 else |
|
891 { |
|
892 // If i am viewing or editing only an instance, the alarm date and time |
|
893 // should be with respect to the instance only. This could also be the case where |
|
894 // there are no RDates before the start date and the user could be editing the series |
|
895 // in that case. |
|
896 alarmDeltaDays = alarmDateTime.DaysFrom( aInstanceDateTime.TimeLocalL() ); |
|
897 |
|
898 deltaDays = alarmDeltaDays.Int() - alarmOffset.Int(); |
|
899 alarmDateTime -= deltaDays; |
|
900 } |
|
901 } |
|
902 else // If there are no RDates, the behaviour is obvious. |
|
903 { |
|
904 deltaDays = aInstanceDateTime.TimeLocalL().DaysFrom( aEntry.StartTimeL().TimeLocalL() ); |
|
905 alarmDateTime += deltaDays; |
|
906 } |
|
907 } |
|
908 |
|
909 // For an entry which is not repeating but has RDates |
|
910 else if( (iRepeatType == ERepeatOther) && hasRDates ) |
|
911 { |
|
912 // It doesn't matter if the user is viewing or editing the non-RDate |
|
913 // instance. This is the default case. But when the user is viewing or |
|
914 // editing a RDate instance, the alarmDateTime has to be adjusted. |
|
915 for( TInt index = 0; index < count; index++ ) |
|
916 { |
|
917 // If the instance matches one of the RDates |
|
918 if( (aInstanceDateTime.TimeLocalL()) == (rdates[ index ].TimeLocalL()) ) |
|
919 { |
|
920 // instanceAlarmDay = actualAlarmDay + (alarmOffsetStart - alarmOffsetInstance) |
|
921 deltaDays = alarmDateTime.DaysFrom( aEntry.StartTimeL().TimeLocalL() ).Int() |
|
922 - alarmDateTime.DaysFrom( aInstanceDateTime.TimeLocalL() ).Int(); |
|
923 alarmDateTime += deltaDays; |
|
924 break; |
|
925 } |
|
926 } |
|
927 } |
|
928 SetAlarmOnL( alarmDateTime ); |
|
929 } |
|
930 else |
|
931 { |
|
932 SetAlarmOffL(); |
|
933 } |
|
934 CleanupStack::PopAndDestroy(); // rdates |
|
935 |
|
936 // Priority - same behaviour as todo/day views. |
|
937 TUint priority( aEntry.PriorityL() ); |
|
938 |
|
939 // Keep priority inside enumeration range |
|
940 TTodoPriority todoPriority; |
|
941 if( !priority ) |
|
942 { |
|
943 todoPriority = ETodoPriorityHigh; |
|
944 } |
|
945 else if( priority > ETodoPriorityLow ) |
|
946 { |
|
947 todoPriority = ETodoPriorityLow; |
|
948 } |
|
949 else |
|
950 { |
|
951 todoPriority = TTodoPriority(priority); |
|
952 } |
|
953 |
|
954 SetPriorityL( todoPriority ); |
|
955 |
|
956 // Synch type |
|
957 // Note: EOpen is Symbian default for new entries |
|
958 TSynchType synchType = CCalenEntryUtil::ESynchPrivate; |
|
959 switch ( aEntry.ReplicationStatusL() ) |
|
960 { |
|
961 case CCalEntry::EOpen: |
|
962 synchType = CCalenEntryUtil::ESynchPublic; |
|
963 break; |
|
964 case CCalEntry::EPrivate: |
|
965 synchType = CCalenEntryUtil::ESynchPrivate; |
|
966 break; |
|
967 case CCalEntry::ERestricted: |
|
968 synchType = CCalenEntryUtil::ESynchNoSync; |
|
969 break; |
|
970 default: |
|
971 __ASSERT_ALWAYS( EFalse, User::Invariant() ); |
|
972 synchType = CCalenEntryUtil::ESynchPrivate; // to please compiler; |
|
973 break; |
|
974 } |
|
975 SetSynchTypeL( synchType ); |
|
976 SetAttachmentCount(aEntry.AttachmentCountL()); |
|
977 |
|
978 TRACE_EXIT_POINT; |
|
979 } |
|
980 |
|
981 // ----------------------------------------------------------------------------- |
|
982 // CCalenEntryUtil::AttachmentNamesL |
|
983 // |
|
984 // ----------------------------------------------------------------------------- |
|
985 // |
|
986 EXPORT_C void CCalenEntryUtil::AttachmentNamesL(RPointerArray<HBufC>& aAttachmentNames) |
|
987 { |
|
988 TRACE_ENTRY_POINT; |
|
989 TInt attachmentCount = iEntry.AttachmentCountL(); |
|
990 CCalAttachment* attachment; |
|
991 TInt attachmentLength(0); |
|
992 for(TInt index=0;index<attachmentCount;index++) |
|
993 { |
|
994 attachment = iEntry.AttachmentL(index); |
|
995 attachmentLength = attachment->Label().Length(); |
|
996 HBufC* attachmentName = HBufC::NewL(attachmentLength); |
|
997 attachmentName->Des().Copy(attachment->Label()); |
|
998 aAttachmentNames.Append(attachmentName); |
|
999 } |
|
1000 TRACE_EXIT_POINT; |
|
1001 } |
|
1002 |
|
1003 // --------------------------------------------------------------------------- |
|
1004 // CalenViewUtils::CheckForAlldayEventL |
|
1005 // Allday event is an event with a duration of n*24h. |
|
1006 // --------------------------------------------------------------------------- |
|
1007 // |
|
1008 EXPORT_C TBool CCalenEntryUtil::CheckForAlldayEventL( TTime aStartTime, TTime aStopTime ) |
|
1009 { |
|
1010 TRACE_ENTRY_POINT; |
|
1011 |
|
1012 TBool allDayEvent(EFalse); |
|
1013 |
|
1014 if( aStartTime == CalenDateUtils::BeginningOfDay( aStartTime ) |
|
1015 && aStopTime == CalenDateUtils::BeginningOfDay( aStopTime ) |
|
1016 && aStartTime != aStopTime ) |
|
1017 { |
|
1018 allDayEvent = ETrue; |
|
1019 } |
|
1020 |
|
1021 TRACE_EXIT_POINT; |
|
1022 return allDayEvent; |
|
1023 } |
|
1024 |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // CalenViewUtils::GetRdatesL |
|
1027 // Get the RDates for the current CCalEntry |
|
1028 // --------------------------------------------------------------------------- |
|
1029 // |
|
1030 EXPORT_C const RArray<TCalTime> CCalenEntryUtil::GetRdatesL() |
|
1031 { |
|
1032 TRACE_ENTRY_POINT; |
|
1033 |
|
1034 RArray<TCalTime> rDateList; |
|
1035 iEntry.GetRDatesL(rDateList); |
|
1036 return rDateList; |
|
1037 |
|
1038 TRACE_EXIT_POINT; |
|
1039 } |
|
1040 |
|
1041 // End of file |