|
1 /* |
|
2 * Copyright (c) 2005 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: This file implements class CESMRCalDbMgr. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include "cesmrcaldbmgr.h" |
|
22 #include "cesmrcaldbnormal.h" |
|
23 #include "cesmrentrycmditeratorao.h" |
|
24 #include "esmrhelper.h" |
|
25 #include "esmrentryhelper.h" |
|
26 #include "mesmrcalentry.h" |
|
27 #include "mesmrutilstombsext.h" |
|
28 #include "mruidomaincrkeys.h" |
|
29 |
|
30 // From System |
|
31 #include <ct/rcpointerarray.h> |
|
32 #include <calsession.h> |
|
33 #include <calentryview.h> |
|
34 #include <calinstance.h> |
|
35 #include <calinstanceview.h> |
|
36 #include <calentry.h> |
|
37 #include <calcommon.h> |
|
38 #include <caluser.h> |
|
39 #include <CalenInterimUtils2.h> |
|
40 #include <sysutil.h> |
|
41 #include <ErrorUI.h> |
|
42 #include <coemain.h> |
|
43 #include <calcalendarinfo.h> |
|
44 #include <centralrepository.h> |
|
45 |
|
46 // CONSTANTS |
|
47 |
|
48 // Unnamed namespace for local definitions |
|
49 namespace { |
|
50 |
|
51 const TInt KDbInitReady( 100 ); |
|
52 |
|
53 /** |
|
54 * Reads last used database index from central repository |
|
55 * |
|
56 * @param aIndex on return contains the last used database index |
|
57 */ |
|
58 void ReadDatabaseIndexL( TInt& aIndex ) |
|
59 { |
|
60 FUNC_LOG; |
|
61 |
|
62 CRepository* repository = CRepository::NewLC( KCRUidESMRUIFeatures ); |
|
63 User::LeaveIfError( repository->Get( KMRUIDefaultCalDbIndex, aIndex ) ); |
|
64 CleanupStack::PopAndDestroy( repository ); |
|
65 } |
|
66 |
|
67 /** |
|
68 * Writes used database index into central repository |
|
69 * |
|
70 * @param database index |
|
71 */ |
|
72 void WriteDatabaseIndexL( TInt aIndex ) |
|
73 { |
|
74 FUNC_LOG; |
|
75 |
|
76 CRepository* repository = CRepository::NewLC( KCRUidESMRUIFeatures ); |
|
77 User::LeaveIfError( repository->Set( KMRUIDefaultCalDbIndex, aIndex ) ); |
|
78 CleanupStack::PopAndDestroy( repository ); |
|
79 } |
|
80 |
|
81 |
|
82 // Panic code definitions |
|
83 enum TPanicCode |
|
84 { |
|
85 EPanicIllegalFetchParams = 1, |
|
86 EPanicAccessedWhenUnavailable, |
|
87 EPanicAsyncOpAlreadyExists, |
|
88 EPanicIllegalEntryStatus, |
|
89 EPanicIllegalResurrect, |
|
90 EPanicUnexpectedUidValue, |
|
91 EPanicLoadMultiDbInfoFail, |
|
92 EPanicInvalidDbIndex |
|
93 }; |
|
94 |
|
95 // Panic string definition |
|
96 _LIT( KPanicMsg, "CESMRCalDbMgr" ); |
|
97 |
|
98 /** |
|
99 * Raises system panic |
|
100 * @param aReason Panic reason. |
|
101 */ |
|
102 void Panic( TPanicCode aReason ) |
|
103 { |
|
104 User::Panic( KPanicMsg, aReason ); |
|
105 } |
|
106 |
|
107 } // namespace |
|
108 |
|
109 |
|
110 // ======== MEMBER FUNCTIONS ======== |
|
111 |
|
112 // ---------------------------------------------------------------------------- |
|
113 // CESMRCalDbMgr::NewL |
|
114 // ---------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C CESMRCalDbMgr* CESMRCalDbMgr::NewL( |
|
117 CCalSession& aCalSession, |
|
118 MMRUtilsObserver& aObserver ) |
|
119 { |
|
120 FUNC_LOG; |
|
121 CESMRCalDbMgr* self = |
|
122 new( ELeave ) CESMRCalDbMgr( |
|
123 aCalSession, |
|
124 aObserver ); |
|
125 CleanupStack::PushL( self ); |
|
126 self->ConstructL(); |
|
127 CleanupStack::Pop(); |
|
128 |
|
129 return self; |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------------- |
|
133 // CESMRCalDbMgr::CESMRCalDbMgr |
|
134 // |
|
135 // Constructor. |
|
136 // ---------------------------------------------------------------------------- |
|
137 // |
|
138 CESMRCalDbMgr::CESMRCalDbMgr( |
|
139 CCalSession& aCalSession, |
|
140 MMRUtilsObserver& aObserver ) |
|
141 : iCurrentAsyncOp( CMRUtils::ENoOperation ), |
|
142 iCalSession( aCalSession ), |
|
143 iObserver( aObserver ) |
|
144 { |
|
145 FUNC_LOG; |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CESMRCalDbMgr::~CESMRCalDbMgr |
|
150 // |
|
151 // Destructor. |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 CESMRCalDbMgr::~CESMRCalDbMgr() |
|
155 { |
|
156 FUNC_LOG; |
|
157 |
|
158 iCalInstanceViewArray.ResetAndDestroy(); |
|
159 iCalEntryViewArray.ResetAndDestroy(); |
|
160 iCalendarInfoArray.ResetAndDestroy(); |
|
161 iCalSessionArray.ResetAndDestroy(); |
|
162 |
|
163 delete iCmdIterator; |
|
164 delete iNormalDb; |
|
165 } |
|
166 |
|
167 // ---------------------------------------------------------------------------- |
|
168 // CESMRCalDbMgr::ConstructL |
|
169 // ---------------------------------------------------------------------------- |
|
170 // |
|
171 void CESMRCalDbMgr::ConstructL() |
|
172 { |
|
173 FUNC_LOG; |
|
174 |
|
175 iNormalDb = CESMRCalDbNormal::NewL( iCalSession, *this, *this ); |
|
176 iCmdIterator = CESMREntryCmdIteratorAO::NewL( *this ); |
|
177 |
|
178 TRAPD( err, LoadMultiCalenInfoL() ); |
|
179 __ASSERT_ALWAYS( err == KErrNone, Panic( EPanicLoadMultiDbInfoFail ) ); |
|
180 User::LeaveIfError( err ); |
|
181 } |
|
182 |
|
183 // ---------------------------------------------------------------------------- |
|
184 // CESMRCalDbMgr::HandleCalDbStatus |
|
185 // ---------------------------------------------------------------------------- |
|
186 // |
|
187 void CESMRCalDbMgr::HandleCalDbStatus( |
|
188 const CESMRCalDbBase* /*aNotifier*/, |
|
189 MESMRCalDbObserver::TDbStatus aStatus ) |
|
190 { |
|
191 FUNC_LOG; |
|
192 |
|
193 if ( aStatus == EReseting ) |
|
194 { // reset db is ongoing, engine becomes unavailable |
|
195 iObserver.HandleCalEngStatus( MMRUtilsObserver::ENotReady ); |
|
196 } |
|
197 else if ( iNormalDb->DbStatus() == MESMRCalDbObserver::EFinishedOk ) |
|
198 { |
|
199 iObserver.HandleCalEngStatus( MMRUtilsObserver::EAvailable ); |
|
200 } |
|
201 else if ( iNormalDb->DbStatus() == MESMRCalDbObserver::EFinishedOk ) |
|
202 { |
|
203 iObserver.HandleCalEngStatus( |
|
204 MMRUtilsObserver::EAvailableWithoutTombs ); |
|
205 } |
|
206 else if ( iNormalDb->DbStatus() == MESMRCalDbObserver::EFinishedError ) |
|
207 { |
|
208 iObserver.HandleCalEngStatus( MMRUtilsObserver::ENotAvailable ); |
|
209 } |
|
210 |
|
211 // In other cases either db is not yet finished |
|
212 } |
|
213 |
|
214 // ---------------------------------------------------------------------------- |
|
215 // CESMRCalDbMgr::Progress |
|
216 // ---------------------------------------------------------------------------- |
|
217 // |
|
218 void CESMRCalDbMgr::Progress( TInt /*aPercentageCompleted*/ ) |
|
219 { |
|
220 FUNC_LOG; |
|
221 // Not interested in progress currently |
|
222 } |
|
223 |
|
224 // ---------------------------------------------------------------------------- |
|
225 // CESMRCalDbMgr::NotifyProgress |
|
226 // ---------------------------------------------------------------------------- |
|
227 // |
|
228 TBool CESMRCalDbMgr::NotifyProgress() |
|
229 { |
|
230 FUNC_LOG; |
|
231 // Not interested in progress currently |
|
232 return EFalse; |
|
233 } |
|
234 |
|
235 // ---------------------------------------------------------------------------- |
|
236 // CESMRCalDbMgr::Completed |
|
237 // ---------------------------------------------------------------------------- |
|
238 // |
|
239 void CESMRCalDbMgr::Completed( TInt aError ) |
|
240 { |
|
241 FUNC_LOG; |
|
242 |
|
243 iObserver.HandleOperation( iCurrentAsyncOp, KDbInitReady, aError ); |
|
244 iCurrentAsyncOp = CMRUtils::ENoOperation; |
|
245 } |
|
246 |
|
247 // ---------------------------------------------------------------------------- |
|
248 // CESMRCalDbMgr::NormalDbEntryView |
|
249 // ---------------------------------------------------------------------------- |
|
250 // |
|
251 CCalEntryView* CESMRCalDbMgr::NormalDbEntryView() |
|
252 { |
|
253 FUNC_LOG; |
|
254 return iNormalDb->EntryView(); |
|
255 } |
|
256 |
|
257 // ---------------------------------------------------------------------------- |
|
258 // CESMRCalDbMgr::NormalDbInstanceView |
|
259 // ---------------------------------------------------------------------------- |
|
260 // |
|
261 CCalInstanceView* CESMRCalDbMgr::NormalDbInstanceView() |
|
262 { |
|
263 FUNC_LOG; |
|
264 return iNormalDb->InstanceView(); |
|
265 } |
|
266 |
|
267 // ---------------------------------------------------------------------------- |
|
268 // CESMRCalDbMgr::NormalDbAllCalenInstanceView |
|
269 // ---------------------------------------------------------------------------- |
|
270 // |
|
271 RPointerArray<CCalInstanceView> CESMRCalDbMgr::NormalDbAllCalenInstanceView() |
|
272 { |
|
273 FUNC_LOG; |
|
274 return iCalInstanceViewArray; |
|
275 } |
|
276 |
|
277 // ---------------------------------------------------------------------------- |
|
278 // CESMRCalDbMgr::FetchEntriesL |
|
279 // ---------------------------------------------------------------------------- |
|
280 // |
|
281 void CESMRCalDbMgr::FetchEntriesL( |
|
282 RPointerArray<CCalEntry>& aCalEntryArray, |
|
283 const CalCommon::TCalTimeRange& aTimeRange ) |
|
284 { |
|
285 FUNC_LOG; |
|
286 |
|
287 __ASSERT_DEBUG( aCalEntryArray.Count() == 0, |
|
288 Panic( EPanicIllegalFetchParams ) ); |
|
289 aCalEntryArray.ResetAndDestroy(); |
|
290 // caller definitely wants to get full copies -> ETrue as 3rd argument: |
|
291 iNormalDb->FetchWithRangeL( aCalEntryArray, |
|
292 aTimeRange, |
|
293 ETrue ); |
|
294 |
|
295 } |
|
296 |
|
297 // ---------------------------------------------------------------------------- |
|
298 // CESMRCalDbMgr::FetchEntryL |
|
299 // ---------------------------------------------------------------------------- |
|
300 // |
|
301 CCalEntry* CESMRCalDbMgr::FetchEntryL( |
|
302 const TDesC8& aUid, |
|
303 const TCalTime& aRecurrenceId ) |
|
304 { |
|
305 FUNC_LOG; |
|
306 |
|
307 __ASSERT_DEBUG( aUid.Length() > 0, |
|
308 Panic( EPanicIllegalFetchParams ) ); |
|
309 |
|
310 RCPointerArray<CCalEntry> tmpFetchArray; |
|
311 CleanupClosePushL( tmpFetchArray ); |
|
312 |
|
313 CCalEntry* retVal = NULL; |
|
314 |
|
315 TInt index( -1 ); |
|
316 if ( EntryExistsInDbL( aUid, |
|
317 aRecurrenceId, |
|
318 *iNormalDb, |
|
319 tmpFetchArray, |
|
320 index ) ) |
|
321 { |
|
322 retVal = tmpFetchArray[index]; |
|
323 tmpFetchArray.Remove( index ); // ownership transferred to retVal |
|
324 } |
|
325 |
|
326 CleanupStack::PopAndDestroy(); // tmpFetchArray |
|
327 |
|
328 return retVal; |
|
329 } |
|
330 |
|
331 // ---------------------------------------------------------------------------- |
|
332 // CESMRCalDbMgr::StoreEntryL |
|
333 // ---------------------------------------------------------------------------- |
|
334 // |
|
335 TInt CESMRCalDbMgr::StoreEntryL( |
|
336 CCalEntry& aCalEntry, |
|
337 TBool aToNormalDb ) |
|
338 { |
|
339 FUNC_LOG; |
|
340 |
|
341 TInt retVal( KErrNone ); |
|
342 |
|
343 if ( CheckSpaceBelowCriticalLevelL() ) |
|
344 { |
|
345 retVal = KErrNoMemory; |
|
346 } |
|
347 |
|
348 else |
|
349 { |
|
350 if( aToNormalDb ) |
|
351 { |
|
352 CCalenInterimUtils2::StoreL( *(iCalEntryViewArray[iCurCalenIndex]), |
|
353 aCalEntry, |
|
354 ETrue ); |
|
355 WriteDatabaseIndexL( iCurCalenIndex ); |
|
356 } |
|
357 } |
|
358 |
|
359 return retVal; |
|
360 } |
|
361 |
|
362 // ---------------------------------------------------------------------------- |
|
363 // CESMRCalDbMgr::UpdateEntryL |
|
364 // ---------------------------------------------------------------------------- |
|
365 // |
|
366 TInt CESMRCalDbMgr::UpdateEntryL( const CCalEntry& aCalEntry ) |
|
367 { |
|
368 FUNC_LOG; |
|
369 |
|
370 RPointerArray<CCalEntry> calEntryTmpArray( 1 ); // entry not own |
|
371 CleanupClosePushL( calEntryTmpArray ); |
|
372 calEntryTmpArray.AppendL( &aCalEntry ); |
|
373 TInt numSuccessfulEntry( 0 ); |
|
374 // entry view surely exists when status is 'available': |
|
375 EntryViewL( aCalEntry )->UpdateL( calEntryTmpArray, numSuccessfulEntry ); |
|
376 TInt retVal( numSuccessfulEntry == 1 ? KErrNone : KErrGeneral ); |
|
377 CleanupStack::Pop(); // calEntryTmpArray, only close array |
|
378 |
|
379 return retVal; |
|
380 } |
|
381 |
|
382 // ---------------------------------------------------------------------------- |
|
383 // CESMRCalDbMgr::DeleteEntryL |
|
384 // ---------------------------------------------------------------------------- |
|
385 // |
|
386 TInt CESMRCalDbMgr::DeleteEntryL( const TDesC8& aUid, TInt aCalenIndex ) |
|
387 { |
|
388 FUNC_LOG; |
|
389 |
|
390 CDesC8ArrayFlat* uidArray = new( ELeave ) CDesC8ArrayFlat( 1 ); |
|
391 CleanupStack::PushL( uidArray ); |
|
392 uidArray->AppendL( aUid ); |
|
393 // entry view surely exists when status is 'available': |
|
394 iCalEntryViewArray[aCalenIndex]->DeleteL( *uidArray ); |
|
395 CleanupStack::PopAndDestroy( uidArray ); |
|
396 |
|
397 return KErrNone; |
|
398 } |
|
399 |
|
400 // ---------------------------------------------------------------------------- |
|
401 // CESMRCalDbMgr::DeleteEntryL |
|
402 // ---------------------------------------------------------------------------- |
|
403 // |
|
404 TInt CESMRCalDbMgr::DeleteEntryL( const TCalLocalUid& aLocalUid, TInt aCalenIndex ) |
|
405 { |
|
406 FUNC_LOG; |
|
407 |
|
408 RArray<TCalLocalUid> localUidArray( 1 ); |
|
409 CleanupClosePushL( localUidArray ); |
|
410 localUidArray.AppendL( aLocalUid ); |
|
411 TInt numSuccessfulEntry( 0 ); |
|
412 iCalEntryViewArray[aCalenIndex]->DeleteL( localUidArray, numSuccessfulEntry ); |
|
413 TInt retVal( numSuccessfulEntry == 1 ? KErrNone : KErrGeneral ); |
|
414 CleanupStack::PopAndDestroy(); // localUidArray |
|
415 |
|
416 |
|
417 return retVal; |
|
418 } |
|
419 |
|
420 // ---------------------------------------------------------------------------- |
|
421 // CESMRCalDbMgr::StoreEntryCondL |
|
422 // aResurrect can only be ETrue if aCheckOnly is EFalse, i.e. when user is |
|
423 // really trying to store something. |
|
424 // ---------------------------------------------------------------------------- |
|
425 // |
|
426 MESMRUtilsTombsExt::TESMRUtilsDbResult CESMRCalDbMgr::StoreEntryCondL( |
|
427 CCalEntry& aCalEntry, |
|
428 TBool aResurrect, |
|
429 TBool aCheckOnly ) |
|
430 { |
|
431 FUNC_LOG; |
|
432 MESMRUtilsTombsExt::TESMRUtilsDbResult entryStatus( |
|
433 MESMRUtilsTombsExt::EUndefined ); |
|
434 |
|
435 if ( CheckSpaceBelowCriticalLevelL() ) |
|
436 { |
|
437 entryStatus = MESMRUtilsTombsExt::EErrorCancelled; |
|
438 } |
|
439 else |
|
440 { |
|
441 RCPointerArray<CCalEntry> tmpFetchArray; |
|
442 CleanupClosePushL( tmpFetchArray ); |
|
443 |
|
444 TInt index( -1 ); |
|
445 |
|
446 // 1. Normal db part, if entry is found in there then tombstones aren't |
|
447 // checked at all: |
|
448 |
|
449 if ( EntryExistsInDbL( aCalEntry, *iNormalDb, tmpFetchArray, index ) ) |
|
450 { // Entry exists in normal db |
|
451 entryStatus = EvaluateExistingEntryL( aCalEntry, |
|
452 *( tmpFetchArray[index] ) ); |
|
453 if ( entryStatus == MESMRUtilsTombsExt::ECheckedValidUpdate && |
|
454 !aCheckOnly ) |
|
455 { |
|
456 StoreEntryL( aCalEntry ); |
|
457 entryStatus = MESMRUtilsTombsExt::EStoredUpdate; |
|
458 } |
|
459 else if ( entryStatus == MESMRUtilsTombsExt::EErrorCancelled && |
|
460 aResurrect ) |
|
461 { |
|
462 __ASSERT_DEBUG( !aCheckOnly, Panic( EPanicIllegalResurrect ) ); |
|
463 StoreEntryL( aCalEntry ); |
|
464 entryStatus = MESMRUtilsTombsExt::EResurrectedCancelled; |
|
465 } |
|
466 // entry can't be new if it exists in the db already: |
|
467 __ASSERT_DEBUG( entryStatus != MESMRUtilsTombsExt::ECheckedValidNew, |
|
468 Panic( EPanicIllegalEntryStatus) ); |
|
469 } |
|
470 |
|
471 // 2. New entry in this phone: |
|
472 |
|
473 else |
|
474 { // Completely new entry (or tombstone has disappeared) |
|
475 entryStatus = EvaluateNewEntryL( aCalEntry ); |
|
476 if ( entryStatus == MESMRUtilsTombsExt::ECheckedValidNew && !aCheckOnly ) |
|
477 { |
|
478 StoreEntryL( aCalEntry ); |
|
479 entryStatus = MESMRUtilsTombsExt::EStoredNew; |
|
480 } |
|
481 |
|
482 // entry can't be update if doesn't exist in the db already: |
|
483 __ASSERT_DEBUG( entryStatus != MESMRUtilsTombsExt::ECheckedValidUpdate, |
|
484 Panic( EPanicIllegalEntryStatus) ); |
|
485 } |
|
486 |
|
487 CleanupStack::PopAndDestroy(); // tmpFetchArray |
|
488 } |
|
489 |
|
490 return entryStatus; |
|
491 } |
|
492 |
|
493 // ---------------------------------------------------------------------------- |
|
494 // CESMRCalDbMgr::DeleteEntryCondL |
|
495 // ---------------------------------------------------------------------------- |
|
496 // |
|
497 void CESMRCalDbMgr::DeleteEntryCondL( const TDesC8& aUid ) |
|
498 { |
|
499 FUNC_LOG; |
|
500 |
|
501 RCPointerArray<CCalEntry> tmpFetchArray; |
|
502 CleanupClosePushL( tmpFetchArray ); |
|
503 |
|
504 // 1. Delete all found entries from normal db: |
|
505 TInt count = iCalEntryViewArray.Count(); |
|
506 for( TInt i(0); i < count; i++ ) |
|
507 { |
|
508 iCalEntryViewArray[i]->FetchL( aUid, tmpFetchArray ); |
|
509 if( tmpFetchArray.Count() > 0 ) |
|
510 { |
|
511 DeleteEntryL( aUid, i ); |
|
512 tmpFetchArray.ResetAndDestroy(); |
|
513 } |
|
514 } |
|
515 |
|
516 CleanupStack::PopAndDestroy(); // tmpFetchArray |
|
517 } |
|
518 |
|
519 // ---------------------------------------------------------------------------- |
|
520 // CESMRCalDbMgr::DeleteEntryCondL |
|
521 // ---------------------------------------------------------------------------- |
|
522 // |
|
523 void CESMRCalDbMgr::DeleteEntryCondL( const TCalLocalUid& aLocalUid ) |
|
524 { |
|
525 FUNC_LOG; |
|
526 |
|
527 TInt count = iCalEntryViewArray.Count(); |
|
528 for( TInt i(0); i < count; i++ ) |
|
529 { |
|
530 CCalEntry* entry = iCalEntryViewArray[i]->FetchL( aLocalUid ); |
|
531 if ( entry ) |
|
532 { |
|
533 CleanupStack::PushL( entry ); |
|
534 DeleteEntryCondL( *entry ); |
|
535 CleanupStack::PopAndDestroy( entry ); |
|
536 } |
|
537 } |
|
538 } |
|
539 |
|
540 // ---------------------------------------------------------------------------- |
|
541 // CESMRCalDbMgr::DeleteEntryCondL |
|
542 // ---------------------------------------------------------------------------- |
|
543 // |
|
544 void CESMRCalDbMgr::DeleteEntryCondL( const CCalEntry& aCalEntry ) |
|
545 { |
|
546 FUNC_LOG; |
|
547 |
|
548 if ( ESMREntryHelper::IsModifyingEntryL( aCalEntry ) ) |
|
549 { |
|
550 // Modifying entry |
|
551 // 1. Delete entry from normal db: |
|
552 |
|
553 CCalInstance* instance = FindInstanceL( (CCalEntry&)aCalEntry ); |
|
554 CleanupStack::PushL( instance ); |
|
555 TInt colId = instance->InstanceIdL().iCollectionId; |
|
556 |
|
557 TInt index = 0; |
|
558 TInt count = iCalSessionArray.Count(); |
|
559 for( TInt i = 0; i < count; i++ ) |
|
560 { |
|
561 if( colId == iCalSessionArray[i]->CollectionIdL() ) |
|
562 { |
|
563 index = i; |
|
564 break; |
|
565 } |
|
566 } |
|
567 iCalEntryViewArray[index]->DeleteL( aCalEntry ); |
|
568 CleanupStack::PopAndDestroy( instance ); |
|
569 } |
|
570 |
|
571 else |
|
572 { // Originating entry, this is the same case as deleting with GUID: |
|
573 DeleteEntryCondL( aCalEntry.UidL() ); |
|
574 } |
|
575 } |
|
576 |
|
577 // ---------------------------------------------------------------------------- |
|
578 // CESMRCalDbMgr::DeleteEntryCondL |
|
579 // ---------------------------------------------------------------------------- |
|
580 // |
|
581 void CESMRCalDbMgr::DeleteEntryCondL( |
|
582 const CalCommon::TCalTimeRange& aCalTimeRange ) |
|
583 { |
|
584 FUNC_LOG; |
|
585 |
|
586 __ASSERT_DEBUG( iCurrentAsyncOp == CMRUtils::ENoOperation, |
|
587 Panic( EPanicAsyncOpAlreadyExists ) ); |
|
588 |
|
589 RCPointerArray<CCalEntry> tmpFetchArray; |
|
590 CleanupClosePushL( tmpFetchArray ); |
|
591 // skeleton copies are enough -> set 3rd argument to EFalse: |
|
592 iNormalDb->FetchWithRangeL( tmpFetchArray, aCalTimeRange, EFalse ); |
|
593 iCmdIterator->StartCmdIterationL( tmpFetchArray, CMRUtils::EDeleteEntries ); |
|
594 iCurrentAsyncOp = CMRUtils::EDeleteEntries; |
|
595 tmpFetchArray.Reset(); // ownership of entries was transferred |
|
596 CleanupStack::PopAndDestroy(); // tmpFetchArray |
|
597 |
|
598 } |
|
599 |
|
600 // ---------------------------------------------------------------------------- |
|
601 // CESMRCalDbMgr::DeleteEntryCondL |
|
602 // ---------------------------------------------------------------------------- |
|
603 // |
|
604 CCalSession& CESMRCalDbMgr::CalSession() |
|
605 { |
|
606 FUNC_LOG; |
|
607 return iCalSession; |
|
608 } |
|
609 |
|
610 // ---------------------------------------------------------------------------- |
|
611 // CESMRCalDbMgr::FindInstanceL |
|
612 // ---------------------------------------------------------------------------- |
|
613 // |
|
614 CCalInstance* CESMRCalDbMgr::FindInstanceL( |
|
615 const CCalEntry& aEntry ) |
|
616 { |
|
617 FUNC_LOG; |
|
618 |
|
619 CCalInstance* instance = NULL; |
|
620 RCPointerArray<CCalInstance> calInstances; |
|
621 CleanupClosePushL( calInstances ); |
|
622 |
|
623 CalCommon::TCalViewFilter instanceFilter = |
|
624 CalCommon::EIncludeAppts | |
|
625 CalCommon::EIncludeEvents | |
|
626 CalCommon::EIncludeReminder | |
|
627 CalCommon::EIncludeAnnivs | |
|
628 CalCommon::EIncludeCompletedTodos | |
|
629 CalCommon::EIncludeIncompletedTodos; |
|
630 |
|
631 // Removing one seconds from start time and adding one second to stop |
|
632 // time. Otherwise wanted entry is not included into results. |
|
633 TCalTime startTime; |
|
634 startTime.SetTimeLocalL( |
|
635 aEntry.StartTimeL().TimeLocalL() - TTimeIntervalSeconds( 1 ) ); |
|
636 TCalTime endTime; |
|
637 endTime.SetTimeLocalL( |
|
638 aEntry.EndTimeL().TimeLocalL() + TTimeIntervalSeconds( 1 ) ); |
|
639 |
|
640 TDateTime start = startTime.TimeLocalL().DateTime(); |
|
641 TDateTime end = endTime.TimeLocalL().DateTime(); |
|
642 |
|
643 CalCommon::TCalTimeRange timeRange( |
|
644 startTime, |
|
645 endTime ); |
|
646 |
|
647 |
|
648 TInt count = iCalInstanceViewArray.Count(); |
|
649 for( TInt i = 0; i < count && !instance; i++ ) |
|
650 { |
|
651 iCalInstanceViewArray[i]->FindInstanceL( |
|
652 calInstances, |
|
653 instanceFilter, |
|
654 timeRange); |
|
655 if( calInstances.Count() > 0 ) |
|
656 { |
|
657 TInt instanceCount( calInstances.Count() ); |
|
658 for (TInt i = 0; (i < instanceCount && !instance); ++i) |
|
659 { |
|
660 CCalEntry& entry = calInstances[i]->Entry(); |
|
661 |
|
662 // Finding the entry we are intrested for |
|
663 if ( !entry.UidL().Compare( aEntry.UidL() ) ) |
|
664 { |
|
665 instance = calInstances[i]; |
|
666 calInstances.Remove( i ); |
|
667 } |
|
668 } |
|
669 } |
|
670 } |
|
671 |
|
672 CleanupStack::PopAndDestroy(); // arrayCleanup |
|
673 return instance; |
|
674 } |
|
675 |
|
676 // ---------------------------------------------------------------------------- |
|
677 // CESMRCalDbMgr::GetCalendarColorByEntryL |
|
678 // ---------------------------------------------------------------------------- |
|
679 // |
|
680 TRgb CESMRCalDbMgr::GetCalendarColorByEntryL(MESMRCalEntry& aEntry) |
|
681 { |
|
682 FUNC_LOG; |
|
683 TInt count = iCalSessionArray.Count(); |
|
684 TRgb color(0); |
|
685 if( count < 1 ) |
|
686 return color; |
|
687 |
|
688 if( !aEntry.IsStoredL() ) |
|
689 { |
|
690 color = iCalendarInfoArray[0]->Color(); |
|
691 } |
|
692 else |
|
693 { |
|
694 CCalInstance* instance = aEntry.InstanceL(); |
|
695 CleanupStack::PushL( instance ); |
|
696 TInt collectionId = instance->InstanceIdL().iCollectionId; |
|
697 |
|
698 for( TInt i = 0; i < count; i++ ) |
|
699 { |
|
700 if( collectionId == iCalSessionArray[i]->CollectionIdL() ) |
|
701 { |
|
702 color = iCalendarInfoArray[i]->Color(); |
|
703 break; |
|
704 } |
|
705 } |
|
706 |
|
707 CleanupStack::PopAndDestroy( instance ); |
|
708 } |
|
709 |
|
710 return color; |
|
711 } |
|
712 // ---------------------------------------------------------------------------- |
|
713 // CESMRCalDbMgr::GetMultiCalendarNameListL |
|
714 // ---------------------------------------------------------------------------- |
|
715 // |
|
716 void CESMRCalDbMgr::GetMultiCalendarNameListL(RArray<TPtrC>& aCalendarNameList) |
|
717 { |
|
718 FUNC_LOG; |
|
719 TInt count = iCalendarInfoArray.Count(); |
|
720 aCalendarNameList.ReserveL( count ); |
|
721 |
|
722 for( TInt i = 0; i < count; i++ ) |
|
723 { |
|
724 const TDesC& calenName = iCalendarInfoArray[i]->NameL(); |
|
725 aCalendarNameList.AppendL( TPtrC( calenName ) ); |
|
726 } |
|
727 } |
|
728 |
|
729 // ---------------------------------------------------------------------------- |
|
730 // CESMRCalDbMgr::GetCalendarNameByEntryL |
|
731 // ---------------------------------------------------------------------------- |
|
732 // |
|
733 TPtrC CESMRCalDbMgr::GetCalendarNameByEntryL(MESMRCalEntry& aEntry) |
|
734 { |
|
735 FUNC_LOG; |
|
736 |
|
737 TInt count = iCalSessionArray.Count(); |
|
738 |
|
739 TRgb color(0); |
|
740 TPtrC calenName; |
|
741 |
|
742 if( !aEntry.IsStoredL() ) |
|
743 { |
|
744 //while create new entry, use current calendar db |
|
745 if( count > 0 ) |
|
746 { |
|
747 calenName.Set(iCalendarInfoArray[iCurCalenIndex]->NameL()); |
|
748 } |
|
749 } |
|
750 else |
|
751 { |
|
752 CCalInstance* instance = NULL; |
|
753 TRAPD( err, instance = aEntry.InstanceL() ); |
|
754 CleanupStack::PushL( instance ); |
|
755 if( err == KErrNotFound || instance == NULL ) |
|
756 calenName.Set(iCalendarInfoArray[iCurCalenIndex]->NameL()); |
|
757 else |
|
758 { |
|
759 TInt collectionId = instance->InstanceIdL().iCollectionId; |
|
760 TBuf<16> val; |
|
761 |
|
762 for( TInt i = 0; i < count; i++ ) |
|
763 { |
|
764 if( collectionId == iCalSessionArray[i]->CollectionIdL() ) |
|
765 { |
|
766 calenName.Set(iCalendarInfoArray[i]->NameL()); |
|
767 break; |
|
768 } |
|
769 } |
|
770 } |
|
771 CleanupStack::PopAndDestroy( instance ); |
|
772 } |
|
773 |
|
774 return calenName; |
|
775 } |
|
776 |
|
777 // ---------------------------------------------------------------------------- |
|
778 // CESMRCalDbMgr::GetCalendarColorByNameL |
|
779 // ---------------------------------------------------------------------------- |
|
780 // |
|
781 TRgb CESMRCalDbMgr::GetCalendarColorByNameL( const TDesC& aCalendarName ) |
|
782 { |
|
783 FUNC_LOG; |
|
784 TInt count = iCalendarInfoArray.Count(); |
|
785 TRgb color(0); |
|
786 |
|
787 for ( TInt i = 0; i < count; i++) |
|
788 { |
|
789 if( aCalendarName.Compare( iCalendarInfoArray[i]->NameL() ) == 0 ) |
|
790 { |
|
791 color = iCalendarInfoArray[i]->Color(); |
|
792 } |
|
793 } |
|
794 |
|
795 return color; |
|
796 } |
|
797 |
|
798 // ---------------------------------------------------------------------------- |
|
799 // CESMRCalDbMgr::SetCurCalendarByNameL |
|
800 // ---------------------------------------------------------------------------- |
|
801 // |
|
802 void CESMRCalDbMgr::SetCurCalendarByNameL( const TDesC& aCalendarName ) |
|
803 { |
|
804 FUNC_LOG; |
|
805 TInt count = iCalendarInfoArray.Count(); |
|
806 |
|
807 for( TInt i(0); i < count; i++ ) |
|
808 { |
|
809 if( aCalendarName.Compare( iCalendarInfoArray[i]->NameL() ) == 0 ) |
|
810 { |
|
811 SetCurCalendarByIndex( i ); |
|
812 break; |
|
813 } |
|
814 } |
|
815 } |
|
816 |
|
817 // ---------------------------------------------------------------------------- |
|
818 // CESMRCalDbMgr::SetCurCalendarByColIdL |
|
819 // ---------------------------------------------------------------------------- |
|
820 // |
|
821 void CESMRCalDbMgr::SetCurCalendarByColIdL( TInt aColId ) |
|
822 { |
|
823 FUNC_LOG; |
|
824 TInt count = iCalSessionArray.Count(); |
|
825 |
|
826 for( TInt i = 0; i < count; i++ ) |
|
827 { |
|
828 if( aColId == iCalSessionArray[i]->CollectionIdL() ) |
|
829 { |
|
830 SetCurCalendarByIndex( i ); |
|
831 break; |
|
832 } |
|
833 } |
|
834 } |
|
835 |
|
836 // ---------------------------------------------------------------------------- |
|
837 // CESMRCalDbMgr::SetCurCalendarByEntry |
|
838 // ---------------------------------------------------------------------------- |
|
839 // |
|
840 void CESMRCalDbMgr::SetCurCalendarByEntryL( MESMRCalEntry& aEntry ) |
|
841 { |
|
842 TPtrC calenName = GetCalendarNameByEntryL( aEntry ); |
|
843 SetCurCalendarByNameL( calenName ); |
|
844 } |
|
845 |
|
846 // ---------------------------------------------------------------------------- |
|
847 // CESMRCalDbMgr::SetCurCalendarByIndex |
|
848 // ---------------------------------------------------------------------------- |
|
849 // |
|
850 void CESMRCalDbMgr::SetCurCalendarByIndex( TInt aIndex ) |
|
851 { |
|
852 FUNC_LOG; |
|
853 iCurCalenIndex = aIndex; |
|
854 } |
|
855 |
|
856 // ---------------------------------------------------------------------------- |
|
857 // CESMRCalDbMgr::SetCurCalendarByDbIdL |
|
858 // ---------------------------------------------------------------------------- |
|
859 // |
|
860 void CESMRCalDbMgr::SetCurCalendarByDbIdL( TCalFileId aDbId ) |
|
861 { |
|
862 FUNC_LOG; |
|
863 |
|
864 for ( TInt i = 0; i < iCalSessionArray.Count(); ++i ) |
|
865 { |
|
866 TCalFileId fileId( KNullFileId ); |
|
867 iCalSessionArray[ i ]->FileIdL( fileId ); |
|
868 |
|
869 if ( fileId == aDbId ) |
|
870 { |
|
871 iCurCalenIndex = i; |
|
872 break; |
|
873 } |
|
874 } |
|
875 } |
|
876 |
|
877 // ---------------------------------------------------------------------------- |
|
878 // CESMRCalDbMgr::GetCurCalendarColor |
|
879 // ---------------------------------------------------------------------------- |
|
880 // |
|
881 TRgb CESMRCalDbMgr::GetCurCalendarColor() |
|
882 { |
|
883 FUNC_LOG; |
|
884 __ASSERT_ALWAYS( |
|
885 iCurCalenIndex < iCalendarInfoArray.Count(), |
|
886 Panic( EPanicInvalidDbIndex ) ); |
|
887 return iCalendarInfoArray[iCurCalenIndex]->Color(); |
|
888 } |
|
889 |
|
890 // ---------------------------------------------------------------------------- |
|
891 // CESMRCalDbMgr::GetCurCalendarColIdL |
|
892 // ---------------------------------------------------------------------------- |
|
893 // |
|
894 TInt CESMRCalDbMgr::GetCurCalendarColIdL() |
|
895 { |
|
896 FUNC_LOG; |
|
897 __ASSERT_ALWAYS( |
|
898 iCurCalenIndex < iCalSessionArray.Count(), |
|
899 Panic( EPanicInvalidDbIndex ) ); |
|
900 |
|
901 return iCalSessionArray[iCurCalenIndex]->CollectionIdL(); |
|
902 } |
|
903 |
|
904 // ---------------------------------------------------------------------------- |
|
905 // CESMRCalDbMgr::GetCurCalendarIndex |
|
906 // ---------------------------------------------------------------------------- |
|
907 // |
|
908 TInt CESMRCalDbMgr::GetCurCalendarIndex() |
|
909 { |
|
910 return iCurCalenIndex; |
|
911 } |
|
912 |
|
913 // ---------------------------------------------------------------------------- |
|
914 // CESMRCalDbMgr::EntryViewL |
|
915 // ---------------------------------------------------------------------------- |
|
916 // |
|
917 CCalEntryView* CESMRCalDbMgr::EntryViewL(const CCalEntry& aCalEntry ) |
|
918 { |
|
919 FUNC_LOG; |
|
920 CCalInstance* instance = FindInstanceL( aCalEntry ); |
|
921 if( !instance ) |
|
922 { |
|
923 return NULL; |
|
924 } |
|
925 |
|
926 CleanupStack::PushL( instance ); |
|
927 CCalEntryView* entryView = NULL; |
|
928 |
|
929 TInt colId = instance->InstanceIdL().iCollectionId; |
|
930 TInt count = iCalSessionArray.Count(); |
|
931 |
|
932 for( TInt i = 0; i < count; i++ ) |
|
933 { |
|
934 if( colId == iCalSessionArray[i]->CollectionIdL() ) |
|
935 { |
|
936 entryView = iCalEntryViewArray[i]; |
|
937 break; |
|
938 } |
|
939 } |
|
940 |
|
941 if ( !entryView ) |
|
942 { |
|
943 User::Leave( KErrNotFound ); |
|
944 } |
|
945 |
|
946 CleanupStack::PopAndDestroy( instance ); |
|
947 return entryView; |
|
948 } |
|
949 |
|
950 // ---------------------------------------------------------------------------- |
|
951 // CESMRCalDbMgr::InstanceViewL |
|
952 // ---------------------------------------------------------------------------- |
|
953 // |
|
954 CCalInstanceView* CESMRCalDbMgr::InstanceViewL(const CCalEntry& aCalEntry ) |
|
955 { |
|
956 FUNC_LOG; |
|
957 CCalInstance* instance = FindInstanceL( aCalEntry ); |
|
958 if( !instance ) |
|
959 { |
|
960 return NULL; |
|
961 } |
|
962 |
|
963 CleanupStack::PushL( instance ); |
|
964 CCalInstanceView* instanceView = NULL; |
|
965 |
|
966 TInt colId = instance->InstanceIdL().iCollectionId; |
|
967 TInt count = iCalSessionArray.Count(); |
|
968 |
|
969 for( TInt i = 0; i < count; i++ ) |
|
970 { |
|
971 if( colId == iCalSessionArray[i]->CollectionIdL() ) |
|
972 { |
|
973 instanceView = iCalInstanceViewArray[i]; |
|
974 break; |
|
975 } |
|
976 } |
|
977 |
|
978 if ( !instanceView ) |
|
979 { |
|
980 User::Leave( KErrNotFound ); |
|
981 } |
|
982 |
|
983 CleanupStack::PopAndDestroy( instance ); |
|
984 return instanceView; |
|
985 } |
|
986 |
|
987 // ---------------------------------------------------------------------------- |
|
988 // CESMRCalDbMgr::EntryView |
|
989 // ---------------------------------------------------------------------------- |
|
990 // |
|
991 CCalEntryView* CESMRCalDbMgr::EntryView() |
|
992 { |
|
993 FUNC_LOG; |
|
994 __ASSERT_ALWAYS( |
|
995 iCurCalenIndex < iCalEntryViewArray.Count(), |
|
996 Panic( EPanicInvalidDbIndex ) ); |
|
997 return iCalEntryViewArray[iCurCalenIndex]; |
|
998 } |
|
999 |
|
1000 |
|
1001 |
|
1002 // ---------------------------------------------------------------------------- |
|
1003 // CESMRCalDbMgr::EntryExistsInDbL |
|
1004 // ---------------------------------------------------------------------------- |
|
1005 // |
|
1006 TBool CESMRCalDbMgr::EntryExistsInDbL( |
|
1007 const TDesC8& aUid, |
|
1008 const TCalTime& aRecurrenceId, |
|
1009 const CESMRCalDbBase& /*aDb*/, |
|
1010 RPointerArray<CCalEntry>& aCalEntryArray, |
|
1011 TInt& aIndex ) const |
|
1012 { |
|
1013 FUNC_LOG; |
|
1014 |
|
1015 TBool retVal( EFalse ); |
|
1016 aIndex = KErrNotFound; |
|
1017 |
|
1018 TInt sessionCount = iCalSessionArray.Count(); |
|
1019 for( TInt i = 0; i < sessionCount; i++ ) |
|
1020 { |
|
1021 iCalEntryViewArray[i]->FetchL( aUid, aCalEntryArray ); |
|
1022 if( aCalEntryArray.Count() > 0) |
|
1023 { |
|
1024 break; |
|
1025 } |
|
1026 } |
|
1027 |
|
1028 TInt count( aCalEntryArray.Count() ); |
|
1029 for ( TInt i( 0 ); i < count; ++i ) |
|
1030 { |
|
1031 const CCalEntry& dbEntry( *( aCalEntryArray[i] ) ); |
|
1032 if ( aRecurrenceId.TimeUtcL() == dbEntry.RecurrenceIdL().TimeUtcL() ) |
|
1033 { // Entry was found in the db, |
|
1034 // it may be either originating or modifying entry |
|
1035 retVal = ETrue; |
|
1036 aIndex = i; |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 return retVal; |
|
1041 } |
|
1042 |
|
1043 // ---------------------------------------------------------------------------- |
|
1044 // CESMRCalDbMgr::EntryExistsInDbL |
|
1045 // ---------------------------------------------------------------------------- |
|
1046 // |
|
1047 inline TBool CESMRCalDbMgr::EntryExistsInDbL( |
|
1048 const CCalEntry& aEntry, |
|
1049 const CESMRCalDbBase& aDb, |
|
1050 RPointerArray<CCalEntry>& aCalEntryArray, |
|
1051 TInt& aIndex ) const |
|
1052 { |
|
1053 FUNC_LOG; |
|
1054 return EntryExistsInDbL( aEntry.UidL(), |
|
1055 aEntry.RecurrenceIdL(), |
|
1056 aDb, |
|
1057 aCalEntryArray, |
|
1058 aIndex ); |
|
1059 } |
|
1060 |
|
1061 // ---------------------------------------------------------------------------- |
|
1062 // CESMRCalDbMgr::EvaluateExistingEntryL |
|
1063 // ---------------------------------------------------------------------------- |
|
1064 // |
|
1065 MESMRUtilsTombsExt::TESMRUtilsDbResult CESMRCalDbMgr::EvaluateExistingEntryL( |
|
1066 const CCalEntry& aEntry, |
|
1067 const CCalEntry& aDbEntry ) const |
|
1068 { |
|
1069 FUNC_LOG; |
|
1070 |
|
1071 __ASSERT_DEBUG( aEntry.UidL() == aDbEntry.UidL(), |
|
1072 Panic( EPanicUnexpectedUidValue ) ); |
|
1073 |
|
1074 MESMRUtilsTombsExt::TESMRUtilsDbResult retVal( |
|
1075 MESMRUtilsTombsExt::EUndefined ); |
|
1076 |
|
1077 TInt seq( aEntry.SequenceNumberL() ); |
|
1078 TInt dbSeq( aDbEntry.SequenceNumberL() ); |
|
1079 TTime stamp = aEntry.DTStampL().TimeUtcL(); |
|
1080 TTime dbStamp = aDbEntry.DTStampL().TimeUtcL(); |
|
1081 |
|
1082 if ( ( seq >= dbSeq ) && ( stamp >= dbStamp ) ) |
|
1083 { |
|
1084 if ( ( seq == dbSeq ) && ( stamp == dbStamp ) ) |
|
1085 { |
|
1086 retVal = MESMRUtilsTombsExt::EErrorIdenticalExists; |
|
1087 } |
|
1088 |
|
1089 else if ( aDbEntry.StatusL() == CCalEntry::ECancelled ) |
|
1090 { |
|
1091 retVal = MESMRUtilsTombsExt::EErrorCancelled; |
|
1092 } |
|
1093 else |
|
1094 { |
|
1095 retVal = MESMRUtilsTombsExt::ECheckedValidUpdate; |
|
1096 } |
|
1097 } |
|
1098 else |
|
1099 { |
|
1100 retVal = MESMRUtilsTombsExt::EErrorObsolete; |
|
1101 } |
|
1102 |
|
1103 return retVal; |
|
1104 } |
|
1105 |
|
1106 // ---------------------------------------------------------------------------- |
|
1107 // CESMRCalDbMgr::EvaluateNewEntryL |
|
1108 // This method is only used with iNormalDb |
|
1109 // ---------------------------------------------------------------------------- |
|
1110 // |
|
1111 MESMRUtilsTombsExt::TESMRUtilsDbResult CESMRCalDbMgr::EvaluateNewEntryL( |
|
1112 const CCalEntry& aEntry ) const |
|
1113 { |
|
1114 FUNC_LOG; |
|
1115 |
|
1116 MESMRUtilsTombsExt::TESMRUtilsDbResult retVal( MESMRUtilsTombsExt::EUndefined ); |
|
1117 |
|
1118 if ( ESMREntryHelper::IsModifyingEntryL( aEntry ) && |
|
1119 !IsValidNewModL( aEntry ) ) |
|
1120 { // recurrence id does not match to any instance of an entry |
|
1121 retVal = MESMRUtilsTombsExt::EErrorRecurrence; |
|
1122 } |
|
1123 else |
|
1124 { |
|
1125 retVal = MESMRUtilsTombsExt::ECheckedValidNew; |
|
1126 } |
|
1127 |
|
1128 return retVal; |
|
1129 } |
|
1130 |
|
1131 // ---------------------------------------------------------------------------- |
|
1132 // CESMRCalDbMgr::EvaluateNewEntryL |
|
1133 // This method is only used with iNormalDb |
|
1134 // ---------------------------------------------------------------------------- |
|
1135 // |
|
1136 TBool CESMRCalDbMgr::IsValidNewModL( const CCalEntry& aModEntry ) const |
|
1137 { |
|
1138 FUNC_LOG; |
|
1139 |
|
1140 TBool retVal( EFalse ); |
|
1141 RCPointerArray<CCalInstance> instances; // takes ownership |
|
1142 CleanupClosePushL( instances ); |
|
1143 TCalTime recurrenceId( aModEntry.RecurrenceIdL() ); |
|
1144 CalCommon::TCalTimeRange range( recurrenceId, recurrenceId ); |
|
1145 |
|
1146 iNormalDb->InstanceView()->FindInstanceL( instances, |
|
1147 CalCommon::EIncludeAppts, |
|
1148 range ); |
|
1149 TInt count( instances.Count() ); |
|
1150 |
|
1151 // The entry can also be in other calendar than the default one, |
|
1152 // so the instance view array should be checked in this case. |
|
1153 if( count == 0 ) |
|
1154 { |
|
1155 TInt instanceViewCount = iCalInstanceViewArray.Count(); |
|
1156 for( TInt i(0); i < instanceViewCount; i++ ) |
|
1157 { |
|
1158 iCalInstanceViewArray[i]->FindInstanceL( instances, |
|
1159 CalCommon::EIncludeAppts, |
|
1160 range ); |
|
1161 } |
|
1162 count = instances.Count(); |
|
1163 } |
|
1164 |
|
1165 for ( TInt i( 0 ); i < count; ++i ) |
|
1166 { |
|
1167 // When creating a new modifying entry, recurrence id must match |
|
1168 // to an existing instance start time (later on start time may get |
|
1169 // modified whereas recurrence id remains unchanged). |
|
1170 if ( instances[i]->Entry().UidL() == aModEntry.UidL() && |
|
1171 instances[i]->StartTimeL().TimeUtcL() == recurrenceId.TimeUtcL() ) |
|
1172 { |
|
1173 retVal = ETrue; |
|
1174 break; // match found, ready to return |
|
1175 } |
|
1176 } |
|
1177 CleanupStack::PopAndDestroy(); // instances, delete array items |
|
1178 |
|
1179 return retVal; |
|
1180 } |
|
1181 |
|
1182 // ---------------------------------------------------------------------------- |
|
1183 // CESMRCalDbMgr::OriginatingExistInDbL |
|
1184 // This method is only used with iNormalDb |
|
1185 // ---------------------------------------------------------------------------- |
|
1186 // |
|
1187 TBool CESMRCalDbMgr::OriginatingExistInDbL( |
|
1188 const CCalEntry& aModEntry ) |
|
1189 { |
|
1190 FUNC_LOG; |
|
1191 |
|
1192 TInt retVal( EFalse ); |
|
1193 CCalEntry* dbEntry = FetchEntryL( aModEntry.UidL(), TCalTime() ); |
|
1194 if ( dbEntry ) |
|
1195 { |
|
1196 delete dbEntry; |
|
1197 retVal = ETrue; |
|
1198 } |
|
1199 |
|
1200 return retVal; |
|
1201 } |
|
1202 |
|
1203 // --------------------------------------------------------------------------- |
|
1204 // CESMRCalDbMgr::CheckSpaceBelowCriticalLevelL |
|
1205 // --------------------------------------------------------------------------- |
|
1206 // |
|
1207 TBool CESMRCalDbMgr::CheckSpaceBelowCriticalLevelL() |
|
1208 { |
|
1209 FUNC_LOG; |
|
1210 |
|
1211 TBool retcode(EFalse); |
|
1212 |
|
1213 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
1214 |
|
1215 if ( SysUtil::FFSSpaceBelowCriticalLevelL( &( coeEnv->FsSession() ) ) ) |
|
1216 { |
|
1217 CErrorUI* errorUi = CErrorUI::NewLC(); |
|
1218 errorUi->ShowGlobalErrorNoteL( KErrDiskFull ); |
|
1219 CleanupStack::PopAndDestroy(); // errorUi |
|
1220 retcode = ETrue; |
|
1221 } |
|
1222 |
|
1223 return retcode; |
|
1224 } |
|
1225 |
|
1226 // --------------------------------------------------------------------------- |
|
1227 // CESMRCalDbMgr::LoadMultiCalenInfo |
|
1228 // --------------------------------------------------------------------------- |
|
1229 // |
|
1230 void CESMRCalDbMgr::LoadMultiCalenInfoL() |
|
1231 { |
|
1232 FUNC_LOG; |
|
1233 |
|
1234 CDesCArray* fileArray = iCalSession.ListCalFilesL(); |
|
1235 CleanupStack::PushL( fileArray ); |
|
1236 |
|
1237 TInt count = fileArray->Count(); |
|
1238 |
|
1239 iCalSessionArray.ReserveL( count ); |
|
1240 iCalEntryViewArray.ReserveL( count ); |
|
1241 iCalInstanceViewArray.ReserveL( count ); |
|
1242 iCalendarInfoArray.ReserveL( count ); |
|
1243 |
|
1244 for( TInt i = 0; i < count; i++ ) |
|
1245 { |
|
1246 CCalSession* file = CCalSession::NewL(); |
|
1247 CleanupStack::PushL( file ); |
|
1248 |
|
1249 const TDesC& fileName = (*fileArray)[i]; |
|
1250 file->OpenL( fileName ); |
|
1251 CCalCalendarInfo* calendarInfo = file->CalendarInfoL(); |
|
1252 |
|
1253 if( calendarInfo->IsValid() |
|
1254 && calendarInfo->Enabled() ) |
|
1255 { |
|
1256 // Push info into CleanupStack because NewL may leave |
|
1257 CleanupStack::PushL( calendarInfo ); |
|
1258 |
|
1259 CCalEntryView* entryView = CCalEntryView::NewL( *file ); |
|
1260 // Push entryView into CleanupStack because NewL may leave |
|
1261 CleanupStack::PushL( entryView ); |
|
1262 |
|
1263 CCalInstanceView* instanceView = CCalInstanceView::NewL( *file ); |
|
1264 |
|
1265 // Space has been reserved so AppendL won't leave |
|
1266 iCalInstanceViewArray.AppendL( instanceView ); |
|
1267 |
|
1268 iCalEntryViewArray.AppendL( entryView ); |
|
1269 CleanupStack::Pop( entryView ); |
|
1270 |
|
1271 iCalendarInfoArray.AppendL( calendarInfo ); |
|
1272 CleanupStack::Pop( calendarInfo ); |
|
1273 |
|
1274 iCalSessionArray.AppendL( file ); |
|
1275 CleanupStack::Pop( file ); |
|
1276 } |
|
1277 else |
|
1278 { |
|
1279 delete calendarInfo; |
|
1280 CleanupStack::PopAndDestroy( file ); |
|
1281 } |
|
1282 } |
|
1283 |
|
1284 CleanupStack::PopAndDestroy( fileArray ); |
|
1285 |
|
1286 // Restore default database index from repository |
|
1287 ReadDatabaseIndexL( iCurCalenIndex ); |
|
1288 } |
|
1289 |
|
1290 |
|
1291 // End of file |
|
1292 |
|
1293 |