|
1 /* |
|
2 * Copyright (c) 2002 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: Provides asynchronous wrapper functions for |
|
15 * common InterimAPI operations. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 //debug |
|
21 #include "calendarui_debug.h" |
|
22 |
|
23 // INCLUDES |
|
24 #include "CalenAsyncCommands.h" |
|
25 #include "CalenEngine.h" |
|
26 #include "calenagendautils.h" |
|
27 #include "calendateutils.h" |
|
28 #include "CleanupResetAndDestroy.h" |
|
29 |
|
30 #include <calsession.h> |
|
31 #include <calcommon.h> |
|
32 #include <calinstance.h> |
|
33 #include <calinstanceview.h> |
|
34 |
|
35 #include "CalenPaths.h" |
|
36 |
|
37 //////////////////////////////////////////////////////////////////////// |
|
38 // CMultiStepCommandBase method definitions |
|
39 /////////////////////////////////////////////////////////////////////// |
|
40 |
|
41 CMultistepCommandBase::CMultistepCommandBase(CCalenEngine& aEngine) : |
|
42 CActive( 0 ), |
|
43 iEngine( aEngine ) |
|
44 { |
|
45 TRACE_ENTRY_POINT; |
|
46 |
|
47 CActiveScheduler::Add( this ); |
|
48 |
|
49 TRACE_EXIT_POINT; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // ?classname::?member_function |
|
54 // ?implementation_description |
|
55 // (other items were commented in a header). |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CMultistepCommandBase::~CMultistepCommandBase() |
|
59 { |
|
60 TRACE_ENTRY_POINT; |
|
61 |
|
62 /* !!! NOTE !!! |
|
63 * Do NOT call Cancel() in here. |
|
64 * Calling Cancel() will cause the code to panic! |
|
65 * Cancel() can only be called in a class that implements |
|
66 * the DoCancel() function. |
|
67 */ |
|
68 |
|
69 TRACE_EXIT_POINT; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // ?classname::?member_function |
|
74 // ?implementation_description |
|
75 // (other items were commented in a header). |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CMultistepCommandBase::Start() |
|
79 { |
|
80 TRACE_ENTRY_POINT; |
|
81 |
|
82 CompleteSelf(); |
|
83 |
|
84 TRACE_EXIT_POINT; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // ?classname::?member_function |
|
89 // ?implementation_description |
|
90 // (other items were commented in a header). |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CMultistepCommandBase::CompleteSelf() |
|
94 { |
|
95 TRACE_ENTRY_POINT; |
|
96 |
|
97 TRequestStatus* pStat = &iStatus; |
|
98 User::RequestComplete( pStat, KErrNone ); |
|
99 |
|
100 if( IsAdded() ) |
|
101 { |
|
102 SetActive(); |
|
103 } |
|
104 |
|
105 TRACE_EXIT_POINT; |
|
106 } |
|
107 |
|
108 |
|
109 //////////////////////////////////////////////////////////////////////// |
|
110 // COpenCommand method definitions |
|
111 /////////////////////////////////////////////////////////////////////// |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // ?classname::?member_function |
|
115 // ?implementation_description |
|
116 // (other items were commented in a header). |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 COpenCommand::COpenCommand(CCalenEngine& aEngine) |
|
120 : CMultistepCommandBase( aEngine ), |
|
121 iState( ECreateSession ), |
|
122 iAgendaError( KErrNone ) |
|
123 { |
|
124 TRACE_ENTRY_POINT; |
|
125 TRACE_EXIT_POINT; |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // ?classname::?member_function |
|
130 // ?implementation_description |
|
131 // (other items were commented in a header). |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 COpenCommand::~COpenCommand() |
|
135 { |
|
136 TRACE_ENTRY_POINT; |
|
137 |
|
138 Cancel(); |
|
139 |
|
140 TRACE_EXIT_POINT; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // ?classname::?member_function |
|
145 // ?implementation_description |
|
146 // (other items were commented in a header). |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void COpenCommand::Panic(TInt aReason) |
|
150 { |
|
151 TRACE_ENTRY_POINT; |
|
152 |
|
153 __ASSERT_DEBUG( EFalse, User::Panic( _L("COpenCommand"), aReason ) ); |
|
154 |
|
155 TRACE_EXIT_POINT; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // ?classname::?member_function |
|
160 // ?implementation_description |
|
161 // (other items were commented in a header). |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void COpenCommand::RunL() |
|
165 { |
|
166 TRACE_ENTRY_POINT; |
|
167 |
|
168 switch( iState ) |
|
169 { |
|
170 case ECreateSession: |
|
171 { |
|
172 iEngine.UpdateCalSessionsL(); |
|
173 |
|
174 iState = ECreateView; |
|
175 CompleteSelf(); |
|
176 } |
|
177 break; |
|
178 |
|
179 case ECreateView: |
|
180 { |
|
181 |
|
182 if(iEngine.iInstanceView) |
|
183 { |
|
184 delete iEngine.iInstanceView; |
|
185 iEngine.iInstanceView = NULL; |
|
186 } |
|
187 |
|
188 RPointerArray<CCalSession>& sessionArray = iEngine.GetActiveSessionsL(); |
|
189 // Creating a view will create the index |
|
190 // This is an asynch function: |
|
191 // -> we don't complete ourselves here, agenda model calls back to the Completed method. |
|
192 |
|
193 |
|
194 if(sessionArray.Count()) |
|
195 { |
|
196 iEngine.iInstanceView = CCalInstanceView::NewL( sessionArray, *this ); |
|
197 } |
|
198 } |
|
199 break; |
|
200 |
|
201 case ESignalCaller: |
|
202 { |
|
203 User::LeaveIfError( iAgendaError ); |
|
204 iState = EReady; |
|
205 iEngine.OpenCompleted(); |
|
206 } |
|
207 break; |
|
208 |
|
209 default: |
|
210 { |
|
211 Panic( EInvalidState ); |
|
212 } |
|
213 } |
|
214 |
|
215 TRACE_EXIT_POINT; |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // ?classname::?member_function |
|
220 // ?implementation_description |
|
221 // (other items were commented in a header). |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 void COpenCommand::DoCancel() |
|
225 { |
|
226 TRACE_ENTRY_POINT; |
|
227 |
|
228 iState = ECreateSession; |
|
229 iEngine.ReleaseCalendarDatabase(); |
|
230 |
|
231 TRACE_EXIT_POINT; |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // ?classname::?member_function |
|
236 // ?implementation_description |
|
237 // (other items were commented in a header). |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void COpenCommand::Completed(TInt aError) |
|
241 { |
|
242 TRACE_ENTRY_POINT; |
|
243 |
|
244 iAgendaError = aError; |
|
245 iState = ESignalCaller; |
|
246 CompleteSelf(); |
|
247 |
|
248 TRACE_EXIT_POINT; |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // ?classname::?member_function |
|
253 // ?implementation_description |
|
254 // (other items were commented in a header). |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 void COpenCommand::Progress(TInt /*aPercentageCompleted*/) |
|
258 { |
|
259 TRACE_ENTRY_POINT; |
|
260 |
|
261 // do not care about progress, only completion matters |
|
262 TRACE_EXIT_POINT; |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // ?classname::?member_function |
|
267 // ?implementation_description |
|
268 // (other items were commented in a header). |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 TBool COpenCommand::NotifyProgress() |
|
272 { |
|
273 TRACE_ENTRY_POINT; |
|
274 |
|
275 TRACE_EXIT_POINT; |
|
276 return EFalse; |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // ?classname::?member_function |
|
281 // ?implementation_description |
|
282 // (other items were commented in a header). |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 TInt COpenCommand::RunError(TInt aError) |
|
286 { |
|
287 TRACE_ENTRY_POINT; |
|
288 |
|
289 // suppress any error |
|
290 iEngine.ReleaseCalendarDatabase(); |
|
291 iEngine.HandleError( aError ); |
|
292 |
|
293 TRACE_EXIT_POINT; |
|
294 return KErrNone; |
|
295 } |
|
296 |
|
297 //////////////////////////////////////////////////////////////////////// |
|
298 // CGetEntrisCommand method definitions |
|
299 /////////////////////////////////////////////////////////////////////// |
|
300 |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // ?classname::?member_function |
|
304 // ?implementation_description |
|
305 // (other items were commented in a header). |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 CGetEntriesCommand* CGetEntriesCommand::NewL( CCalenEngine& aEngine, |
|
309 const TTime& aDay, |
|
310 RPointerArray<CCalInstance>& aInstanceArray ) |
|
311 { |
|
312 TRACE_ENTRY_POINT; |
|
313 |
|
314 CGetEntriesCommand* self = new( ELeave )CGetEntriesCommand( aEngine, aDay, aInstanceArray ); |
|
315 |
|
316 TRACE_EXIT_POINT; |
|
317 return self; |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // ?classname::?member_function |
|
322 // ?implementation_description |
|
323 // (other items were commented in a header). |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 CGetEntriesCommand::CGetEntriesCommand( CCalenEngine& aEngine, |
|
327 const TTime& aDay, |
|
328 RPointerArray<CCalInstance>& aInstanceArray ) |
|
329 : CMultistepCommandBase( aEngine ), |
|
330 iState( EFetch ), |
|
331 iDay( aDay ), |
|
332 iInstanceArray( aInstanceArray ) |
|
333 { |
|
334 TRACE_ENTRY_POINT; |
|
335 TRACE_EXIT_POINT; |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // ?classname::?member_function |
|
340 // ?implementation_description |
|
341 // (other items were commented in a header). |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 CGetEntriesCommand::~CGetEntriesCommand() |
|
345 { |
|
346 TRACE_ENTRY_POINT; |
|
347 |
|
348 Cancel(); |
|
349 |
|
350 TRACE_EXIT_POINT; |
|
351 } |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // ?classname::?member_function |
|
355 // ?implementation_description |
|
356 // (other items were commented in a header). |
|
357 // ----------------------------------------------------------------------------- |
|
358 // |
|
359 void CGetEntriesCommand::RunL(void) |
|
360 { |
|
361 TRACE_ENTRY_POINT; |
|
362 |
|
363 switch( iState ) |
|
364 { |
|
365 case EFetch: |
|
366 { |
|
367 if( !iEngine.iInstanceView ) |
|
368 { |
|
369 // open command / instance view creation failed |
|
370 User::Leave( KErrNotFound ); |
|
371 } |
|
372 else |
|
373 { |
|
374 |
|
375 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAppts | |
|
376 CalCommon::EIncludeReminder | |
|
377 CalCommon::EIncludeEvents | |
|
378 CalCommon::EIncludeAnnivs; |
|
379 |
|
380 CalenAgendaUtils::FindEventsForDayRangeL( iEngine.iInstanceView, iInstanceArray, filter, iDay, iDay ); |
|
381 |
|
382 CalenAgendaUtils::RemoveEntriesEndingAtMidnightL( iInstanceArray, iDay ); |
|
383 |
|
384 iState = EFinalize; |
|
385 CompleteSelf(); |
|
386 } |
|
387 |
|
388 } |
|
389 break; |
|
390 |
|
391 case EFinalize: |
|
392 { |
|
393 |
|
394 iDay = CalenDateUtils::BeginningOfDay( iDay ); |
|
395 |
|
396 // Remove all events starting before iDay |
|
397 for(TInt i(0); i<iInstanceArray.Count(); ) |
|
398 { |
|
399 if( ( iInstanceArray[i]->Entry().EntryTypeL() == CCalEntry::EAppt || |
|
400 iInstanceArray[i]->Entry().EntryTypeL() == CCalEntry::EReminder ) |
|
401 && |
|
402 iInstanceArray[i]->StartTimeL().TimeLocalL() < iDay ) |
|
403 { |
|
404 delete iInstanceArray[i]; |
|
405 iInstanceArray.Remove( i ); |
|
406 } |
|
407 else |
|
408 { |
|
409 i++; |
|
410 } |
|
411 } |
|
412 |
|
413 CalenAgendaUtils::SortInstanceList( iInstanceArray ); |
|
414 |
|
415 iState = ESignalCaller; |
|
416 CompleteSelf(); |
|
417 |
|
418 } |
|
419 break; |
|
420 |
|
421 case ESignalCaller: |
|
422 { |
|
423 iState = EReady; |
|
424 iEngine.GetEntriesCompleted(); |
|
425 } |
|
426 break; |
|
427 |
|
428 default: |
|
429 { |
|
430 Panic( EInvalidState ); |
|
431 } |
|
432 } |
|
433 |
|
434 TRACE_EXIT_POINT; |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // ?classname::?member_function |
|
439 // ?implementation_description |
|
440 // (other items were commented in a header). |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 void CGetEntriesCommand::DoCancel(void) |
|
444 { |
|
445 TRACE_ENTRY_POINT; |
|
446 |
|
447 iState = EFetch; |
|
448 |
|
449 TRACE_EXIT_POINT; |
|
450 } |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // ?classname::?member_function |
|
454 // ?implementation_description |
|
455 // (other items were commented in a header). |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 TInt CGetEntriesCommand::RunError(TInt aError) |
|
459 { |
|
460 TRACE_ENTRY_POINT; |
|
461 |
|
462 iEngine.HandleError( aError ); |
|
463 |
|
464 TRACE_EXIT_POINT; |
|
465 return KErrNone; |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // ?classname::?member_function |
|
470 // ?implementation_description |
|
471 // (other items were commented in a header). |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void CGetEntriesCommand::Panic(TInt aReason) |
|
475 { |
|
476 TRACE_ENTRY_POINT; |
|
477 |
|
478 __ASSERT_DEBUG( EFalse, User::Panic( _L("CGetEntriesCommand"), aReason ) ); |
|
479 |
|
480 TRACE_EXIT_POINT; |
|
481 } |
|
482 |
|
483 |
|
484 //////////////////////////////////////////////////////////////////////// |
|
485 // CGetNextEventCommand method definitions |
|
486 /////////////////////////////////////////////////////////////////////// |
|
487 |
|
488 // ----------------------------------------------------------------------------- |
|
489 // ?classname::?member_function |
|
490 // ?implementation_description |
|
491 // (other items were commented in a header). |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 CGetNextEventCommand* CGetNextEventCommand::NewL( CCalenEngine& aEngine, |
|
495 const TTime& aStartDay, |
|
496 const TInt aDaysToSearch, |
|
497 RPointerArray<CCalInstance>& aInstanceArray ) |
|
498 { |
|
499 TRACE_ENTRY_POINT; |
|
500 |
|
501 CGetNextEventCommand* self = new( ELeave )CGetNextEventCommand( aEngine, aStartDay, aDaysToSearch, aInstanceArray ); |
|
502 |
|
503 TRACE_EXIT_POINT; |
|
504 return self; |
|
505 } |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // ?classname::?member_function |
|
509 // ?implementation_description |
|
510 // (other items were commented in a header). |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 CGetNextEventCommand::CGetNextEventCommand(CCalenEngine& aEngine, const TTime& aStartDay, const TInt aDaysToSearch, RPointerArray<CCalInstance>& aInstanceArray) |
|
514 : CMultistepCommandBase( aEngine ), |
|
515 iState( EFetch ), |
|
516 iStartDay( aStartDay ), |
|
517 iDaysToSearch( aDaysToSearch ), |
|
518 iInstanceArray( aInstanceArray ) |
|
519 { |
|
520 TRACE_ENTRY_POINT; |
|
521 TRACE_EXIT_POINT; |
|
522 } |
|
523 |
|
524 // ----------------------------------------------------------------------------- |
|
525 // ?classname::?member_function |
|
526 // ?implementation_description |
|
527 // (other items were commented in a header). |
|
528 // ----------------------------------------------------------------------------- |
|
529 // |
|
530 CGetNextEventCommand::~CGetNextEventCommand(void) |
|
531 { |
|
532 TRACE_ENTRY_POINT; |
|
533 |
|
534 Cancel(); |
|
535 iTmpArray.ResetAndDestroy(); |
|
536 |
|
537 TRACE_EXIT_POINT; |
|
538 } |
|
539 |
|
540 // ----------------------------------------------------------------------------- |
|
541 // ?classname::?member_function |
|
542 // ?implementation_description |
|
543 // (other items were commented in a header). |
|
544 // ----------------------------------------------------------------------------- |
|
545 // |
|
546 void CGetNextEventCommand::RunL(void) |
|
547 { |
|
548 TRACE_ENTRY_POINT; |
|
549 |
|
550 switch( iState ) |
|
551 { |
|
552 case EFetch: |
|
553 { |
|
554 // create date range and fetch entries |
|
555 |
|
556 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAppts | |
|
557 CalCommon::EIncludeReminder; |
|
558 |
|
559 TTime endDay = iStartDay +TTimeIntervalDays( iDaysToSearch-1 ); |
|
560 |
|
561 CalenAgendaUtils::FindEventsForDayRangeL( iEngine.iInstanceView, iTmpArray, filter, iStartDay, endDay ); |
|
562 |
|
563 iState = EFinalize; |
|
564 CompleteSelf(); |
|
565 } |
|
566 break; |
|
567 |
|
568 case EFinalize: |
|
569 { |
|
570 if( iTmpArray.Count() ) |
|
571 { |
|
572 CalenAgendaUtils::SortInstanceList( iTmpArray ); |
|
573 |
|
574 iStartDay = CalenDateUtils::BeginningOfDay( iStartDay ); |
|
575 |
|
576 // Find first event starting on iStartDay or later |
|
577 for(TInt i(0); i<iTmpArray.Count(); i++) |
|
578 { |
|
579 if( iTmpArray[i]->StartTimeL().TimeLocalL() >= iStartDay ) |
|
580 { |
|
581 iInstanceArray.AppendL( iTmpArray[i] ); |
|
582 iTmpArray.Remove( i ); |
|
583 break; |
|
584 } |
|
585 } |
|
586 } |
|
587 |
|
588 iTmpArray.ResetAndDestroy(); |
|
589 iState = ESignalCaller; |
|
590 CompleteSelf(); |
|
591 } |
|
592 break; |
|
593 |
|
594 case ESignalCaller: |
|
595 { |
|
596 iState = EReady; |
|
597 iEngine.GetFutureEventCompleted(); |
|
598 } |
|
599 break; |
|
600 |
|
601 default: |
|
602 { |
|
603 Panic( EInvalidState ); |
|
604 } |
|
605 } |
|
606 |
|
607 TRACE_EXIT_POINT; |
|
608 } |
|
609 |
|
610 // ----------------------------------------------------------------------------- |
|
611 // ?classname::?member_function |
|
612 // ?implementation_description |
|
613 // (other items were commented in a header). |
|
614 // ----------------------------------------------------------------------------- |
|
615 // |
|
616 void CGetNextEventCommand::DoCancel(void) |
|
617 { |
|
618 TRACE_ENTRY_POINT; |
|
619 |
|
620 iState = EFetch; |
|
621 |
|
622 TRACE_EXIT_POINT; |
|
623 } |
|
624 |
|
625 // ----------------------------------------------------------------------------- |
|
626 // ?classname::?member_function |
|
627 // ?implementation_description |
|
628 // (other items were commented in a header). |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 TInt CGetNextEventCommand::RunError(TInt aError) |
|
632 { |
|
633 TRACE_ENTRY_POINT; |
|
634 |
|
635 iTmpArray.ResetAndDestroy(); |
|
636 iEngine.HandleError( aError ); |
|
637 |
|
638 TRACE_EXIT_POINT; |
|
639 return KErrNone; |
|
640 } |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // ?classname::?member_function |
|
644 // ?implementation_description |
|
645 // (other items were commented in a header). |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 void CGetNextEventCommand::Panic(TInt aReason) |
|
649 { |
|
650 TRACE_ENTRY_POINT; |
|
651 |
|
652 __ASSERT_DEBUG( EFalse, User::Panic( _L("CGetNextEventCommand"), aReason ) ); |
|
653 |
|
654 TRACE_EXIT_POINT; |
|
655 } |
|
656 |
|
657 |
|
658 /////////////////////////////////////////////////////////////// |
|
659 // CGetTodos |
|
660 /////////////////////////////////////////////////////////////// |
|
661 |
|
662 // ----------------------------------------------------------------------------- |
|
663 // ?classname::?member_function |
|
664 // ?implementation_description |
|
665 // (other items were commented in a header). |
|
666 // ----------------------------------------------------------------------------- |
|
667 // |
|
668 CGetTodosCommand* CGetTodosCommand::NewL( CCalenEngine& aEngine, |
|
669 RPointerArray<CCalInstance>& aInstanceArray ) |
|
670 { |
|
671 TRACE_ENTRY_POINT; |
|
672 |
|
673 CGetTodosCommand* self = new( ELeave )CGetTodosCommand( aEngine, aInstanceArray ); |
|
674 |
|
675 TRACE_EXIT_POINT; |
|
676 return self; |
|
677 } |
|
678 |
|
679 // ----------------------------------------------------------------------------- |
|
680 // ?classname::?member_function |
|
681 // ?implementation_description |
|
682 // (other items were commented in a header). |
|
683 // ----------------------------------------------------------------------------- |
|
684 // |
|
685 CGetTodosCommand::CGetTodosCommand(CCalenEngine& aEngine, RPointerArray<CCalInstance>& aInstanceArray) |
|
686 : CMultistepCommandBase( aEngine ), |
|
687 iState( EFetchInstances ), |
|
688 iInstanceArray( aInstanceArray ) |
|
689 { |
|
690 TRACE_ENTRY_POINT; |
|
691 TRACE_EXIT_POINT; |
|
692 } |
|
693 |
|
694 // ----------------------------------------------------------------------------- |
|
695 // ?classname::?member_function |
|
696 // ?implementation_description |
|
697 // (other items were commented in a header). |
|
698 // ----------------------------------------------------------------------------- |
|
699 // |
|
700 CGetTodosCommand::~CGetTodosCommand() |
|
701 { |
|
702 TRACE_ENTRY_POINT; |
|
703 |
|
704 Cancel(); |
|
705 |
|
706 TRACE_EXIT_POINT; |
|
707 } |
|
708 |
|
709 // ----------------------------------------------------------------------------- |
|
710 // ?classname::?member_function |
|
711 // ?implementation_description |
|
712 // (other items were commented in a header). |
|
713 // ----------------------------------------------------------------------------- |
|
714 // |
|
715 void CGetTodosCommand::RunL(void) |
|
716 { |
|
717 TRACE_ENTRY_POINT; |
|
718 |
|
719 switch( iState ) |
|
720 { |
|
721 case EFetchInstances: |
|
722 { |
|
723 TCalTime dummy; |
|
724 CalCommon::TCalTimeRange dayRange( dummy, dummy ); |
|
725 CalenDateUtils::GetDayRangeL( TCalTime::MinTime(), TCalTime::MaxTime(), dayRange ); |
|
726 |
|
727 if( !iEngine.iInstanceView ) |
|
728 { |
|
729 User::Leave( KErrBadHandle ); // we have a null pointer |
|
730 } |
|
731 |
|
732 iEngine.iInstanceView->FindInstanceL( iInstanceArray, |
|
733 CalCommon::EIncludeIncompletedTodos | |
|
734 // only fetch the first instance for repeating to-dos! |
|
735 CalCommon::EIncludeRptsNextInstanceOnly, |
|
736 dayRange ); |
|
737 |
|
738 iState = ESignalCaller; |
|
739 CompleteSelf(); |
|
740 } |
|
741 break; |
|
742 |
|
743 case ESignalCaller: |
|
744 { |
|
745 iState = EReady; |
|
746 iEngine.GetTodosCompleted(); |
|
747 } |
|
748 break; |
|
749 |
|
750 default: |
|
751 { |
|
752 Panic( EInvalidState ); |
|
753 } |
|
754 } |
|
755 |
|
756 TRACE_EXIT_POINT; |
|
757 } |
|
758 |
|
759 // ----------------------------------------------------------------------------- |
|
760 // ?classname::?member_function |
|
761 // ?implementation_description |
|
762 // (other items were commented in a header). |
|
763 // ----------------------------------------------------------------------------- |
|
764 // |
|
765 void CGetTodosCommand::DoCancel(void) |
|
766 { |
|
767 TRACE_ENTRY_POINT; |
|
768 |
|
769 iState = EFetchInstances; |
|
770 |
|
771 TRACE_EXIT_POINT; |
|
772 } |
|
773 |
|
774 // ----------------------------------------------------------------------------- |
|
775 // ?classname::?member_function |
|
776 // ?implementation_description |
|
777 // (other items were commented in a header). |
|
778 // ----------------------------------------------------------------------------- |
|
779 // |
|
780 TInt CGetTodosCommand::RunError(TInt aError) |
|
781 { |
|
782 TRACE_ENTRY_POINT; |
|
783 |
|
784 iEngine.HandleError( aError ); |
|
785 |
|
786 TRACE_EXIT_POINT; |
|
787 return KErrNone; |
|
788 } |
|
789 |
|
790 // ----------------------------------------------------------------------------- |
|
791 // ?classname::?member_function |
|
792 // ?implementation_description |
|
793 // (other items were commented in a header). |
|
794 // ----------------------------------------------------------------------------- |
|
795 // |
|
796 void CGetTodosCommand::Panic(TInt aReason) |
|
797 { |
|
798 TRACE_ENTRY_POINT; |
|
799 |
|
800 __ASSERT_DEBUG( EFalse, User::Panic( _L("CGetTodosCommand"), aReason ) ); |
|
801 |
|
802 TRACE_EXIT_POINT; |
|
803 } |
|
804 |
|
805 |
|
806 //////////////////////////////////////////////////////////////////////// |
|
807 // CGetEntriesForDaysCommand method definitions |
|
808 /////////////////////////////////////////////////////////////////////// |
|
809 |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // ?classname::?member_function |
|
813 // ?implementation_description |
|
814 // (other items were commented in a header). |
|
815 // ----------------------------------------------------------------------------- |
|
816 // |
|
817 CGetEntriesForDaysCommand* CGetEntriesForDaysCommand::NewL( CCalenEngine& aEngine, |
|
818 RPointerArray<CCalInstance>& aInstanceArray, |
|
819 const TTime& aDay, |
|
820 TInt aDaysToSearch ) |
|
821 { |
|
822 TRACE_ENTRY_POINT; |
|
823 |
|
824 CGetEntriesForDaysCommand* self = new( ELeave )CGetEntriesForDaysCommand( aEngine, aInstanceArray, aDay, aDaysToSearch ); |
|
825 |
|
826 TRACE_EXIT_POINT; |
|
827 return self; |
|
828 } |
|
829 |
|
830 // ----------------------------------------------------------------------------- |
|
831 // ?classname::?member_function |
|
832 // ?implementation_description |
|
833 // (other items were commented in a header). |
|
834 // ----------------------------------------------------------------------------- |
|
835 // |
|
836 CGetEntriesForDaysCommand::CGetEntriesForDaysCommand( CCalenEngine& aEngine, |
|
837 RPointerArray<CCalInstance>& aInstanceArray, |
|
838 const TTime& aDay, |
|
839 TInt aDaysToSearch ) |
|
840 : CMultistepCommandBase( aEngine ), |
|
841 iState( EFetch ), |
|
842 iInstanceArray( aInstanceArray ), |
|
843 iDay( aDay ), |
|
844 iDaysToSearch( aDaysToSearch ) |
|
845 { |
|
846 TRACE_ENTRY_POINT; |
|
847 TRACE_EXIT_POINT; |
|
848 } |
|
849 |
|
850 // ----------------------------------------------------------------------------- |
|
851 // ?classname::?member_function |
|
852 // ?implementation_description |
|
853 // (other items were commented in a header). |
|
854 // ----------------------------------------------------------------------------- |
|
855 // |
|
856 CGetEntriesForDaysCommand::~CGetEntriesForDaysCommand() |
|
857 { |
|
858 TRACE_ENTRY_POINT; |
|
859 |
|
860 Cancel(); |
|
861 |
|
862 TRACE_EXIT_POINT; |
|
863 } |
|
864 |
|
865 // ----------------------------------------------------------------------------- |
|
866 // ?classname::?member_function |
|
867 // ?implementation_description |
|
868 // (other items were commented in a header). |
|
869 // ----------------------------------------------------------------------------- |
|
870 // |
|
871 void CGetEntriesForDaysCommand::RunL(void) |
|
872 { |
|
873 TRACE_ENTRY_POINT; |
|
874 |
|
875 switch( iState ) |
|
876 { |
|
877 case EFetch: |
|
878 { |
|
879 if( !iEngine.iInstanceView ) |
|
880 { |
|
881 // open command / instance view creation failed |
|
882 User::Leave( KErrNotFound ); |
|
883 } |
|
884 else |
|
885 { |
|
886 TTime endDay = iDay +TTimeIntervalDays( iDaysToSearch-1 ); |
|
887 CalCommon::TCalViewFilter filter = CalCommon::EIncludeAppts | |
|
888 CalCommon::EIncludeReminder | |
|
889 CalCommon::EIncludeEvents | |
|
890 CalCommon::EIncludeAnnivs; |
|
891 |
|
892 CalenAgendaUtils::FindTodosForDayRangeL( iEngine.iInstanceView, iInstanceArray, iDay, endDay ); |
|
893 CalenAgendaUtils::FindEventsForDayRangeL( iEngine.iInstanceView, iInstanceArray, filter, iDay, endDay ); |
|
894 CalenAgendaUtils::RemoveEntriesEndingAtMidnightL( iInstanceArray, iDay ); |
|
895 |
|
896 iState = EFinalize; |
|
897 CompleteSelf(); |
|
898 } |
|
899 } |
|
900 break; |
|
901 |
|
902 case EFinalize: |
|
903 { |
|
904 // remove all cancelled meetings |
|
905 for( TInt i(0); i<iInstanceArray.Count(); ) |
|
906 { |
|
907 CCalEntry& entry = iInstanceArray[i]->Entry(); |
|
908 |
|
909 if( entry.EntryTypeL() == CCalEntry::EAppt && |
|
910 entry.StatusL() == CCalEntry::ECancelled ) |
|
911 { |
|
912 delete iInstanceArray[i]; |
|
913 iInstanceArray.Remove( i ); |
|
914 } |
|
915 else |
|
916 { |
|
917 i++; |
|
918 } |
|
919 } |
|
920 |
|
921 CalenAgendaUtils::SortInstanceList( iInstanceArray ); |
|
922 |
|
923 iState = ESignalCaller; |
|
924 CompleteSelf(); |
|
925 } |
|
926 break; |
|
927 |
|
928 case ESignalCaller: |
|
929 { |
|
930 iState = EReady; |
|
931 iEngine.GetCalendarDataCompleted(); |
|
932 } |
|
933 break; |
|
934 |
|
935 default: |
|
936 { |
|
937 Panic( EInvalidState ); |
|
938 } |
|
939 } |
|
940 |
|
941 TRACE_EXIT_POINT; |
|
942 } |
|
943 |
|
944 // ----------------------------------------------------------------------------- |
|
945 // ?classname::?member_function |
|
946 // ?implementation_description |
|
947 // (other items were commented in a header). |
|
948 // ----------------------------------------------------------------------------- |
|
949 // |
|
950 void CGetEntriesForDaysCommand::DoCancel(void) |
|
951 { |
|
952 TRACE_ENTRY_POINT; |
|
953 |
|
954 iState = EFetch; |
|
955 |
|
956 TRACE_EXIT_POINT; |
|
957 } |
|
958 |
|
959 // ----------------------------------------------------------------------------- |
|
960 // ?classname::?member_function |
|
961 // ?implementation_description |
|
962 // (other items were commented in a header). |
|
963 // ----------------------------------------------------------------------------- |
|
964 // |
|
965 TInt CGetEntriesForDaysCommand::RunError(TInt aError) |
|
966 { |
|
967 TRACE_ENTRY_POINT; |
|
968 |
|
969 iEngine.HandleError( aError ); |
|
970 return KErrNone; |
|
971 } |
|
972 |
|
973 // ----------------------------------------------------------------------------- |
|
974 // ?classname::?member_function |
|
975 // ?implementation_description |
|
976 // (other items were commented in a header). |
|
977 // ----------------------------------------------------------------------------- |
|
978 // |
|
979 void CGetEntriesForDaysCommand::Panic(TInt aReason) |
|
980 { |
|
981 TRACE_ENTRY_POINT; |
|
982 |
|
983 __ASSERT_DEBUG( EFalse, User::Panic( _L("CGetEntriesForDaysCommand"), aReason ) ); |
|
984 |
|
985 TRACE_EXIT_POINT; |
|
986 } |
|
987 |
|
988 |
|
989 // End of File |