|
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: |
|
15 * Class for cleaning up unnecessary tombstones. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __CMRUTILSGRAVEYARDCLEANER_H__ |
|
22 #define __CMRUTILSGRAVEYARDCLEANER_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <calprogresscallback.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CMRUtilsCalDbBase; |
|
30 class CCalIter; |
|
31 class CCalEntry; |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * This class performs cleanup for tombstone database asynchronously in the |
|
37 * background. Caller doesn't need to involve this after starting the operation. |
|
38 * This class assumes that databases given are fully initialized. |
|
39 */ |
|
40 class CMRUtilsGraveyardCleaner : public CBase, public MCalProgressCallBack |
|
41 { |
|
42 public: // Data types |
|
43 |
|
44 /** |
|
45 * State of the cleaner object. |
|
46 */ |
|
47 enum TCleanerState |
|
48 { |
|
49 ENotActive, |
|
50 EResurrectedItemsCleanup, |
|
51 ETimeLimitCleanup |
|
52 }; |
|
53 |
|
54 public: // Constructors and destructors |
|
55 |
|
56 |
|
57 /** |
|
58 * Symbian two-phased constructor. |
|
59 * @param aNormalDb database reference |
|
60 * @param aTombsDb database reference |
|
61 * @return instantiated object |
|
62 */ |
|
63 static CMRUtilsGraveyardCleaner* NewL( |
|
64 const CMRUtilsCalDbBase& aNormalDb, |
|
65 CMRUtilsCalDbBase& aTombsDb ); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 ~CMRUtilsGraveyardCleaner(); |
|
71 |
|
72 public: // New functions |
|
73 |
|
74 /** |
|
75 * Starts asynchronous cleanup of tombstones which should be deleted |
|
76 * based on given history time limit, or which have been resurrected |
|
77 * and exist now in the normal database. |
|
78 * @param aTimeLimitUtc older tombstones are deleted using CCalEntryView, |
|
79 * user should give Time::NullTTime() if no time limit is used |
|
80 */ |
|
81 void StartIdleCleanupL( TTime aTimeLimitUtc ); |
|
82 |
|
83 /** |
|
84 * Returns current state of the cleanup object. This method mainly |
|
85 * intended for testing purposes. |
|
86 * @return current state |
|
87 */ |
|
88 TCleanerState CurrentStateL() const; |
|
89 |
|
90 protected: // New functions |
|
91 |
|
92 /** |
|
93 * TCallback method called by the idle cleaner to perform one step. |
|
94 * @param aCleaner object, ownership not transferred |
|
95 * @return 1 if not finished, 0 if finished |
|
96 */ |
|
97 static TInt StepL( TAny* aCleaner ); |
|
98 |
|
99 /** |
|
100 * Helper method for performing one step of clean up task. |
|
101 * @return 1 if not finished, 0 if finished |
|
102 */ |
|
103 TInt DoStepL(); |
|
104 |
|
105 /** |
|
106 * Helper which deletes a tombstone entry if it appears to be resurrected, |
|
107 * i.e. it is found from the normal database as well. |
|
108 * @param aUid specifies entry to check |
|
109 */ |
|
110 void CleanupIfResurrectedL( const TDesC8& aUid ); |
|
111 |
|
112 protected: // From MCalProgressCallBack |
|
113 |
|
114 void Progress( TInt aPercentageCompleted ); |
|
115 |
|
116 TBool NotifyProgress(); |
|
117 |
|
118 void Completed( TInt aError ); |
|
119 |
|
120 protected: // Constructors and destructors |
|
121 |
|
122 /** |
|
123 * C++ default constructor. |
|
124 * @param aNormalDb database reference |
|
125 * @param aTombsDb database reference |
|
126 */ |
|
127 CMRUtilsGraveyardCleaner( const CMRUtilsCalDbBase& aNormalDb, |
|
128 CMRUtilsCalDbBase& aTombsDb ); |
|
129 |
|
130 /** |
|
131 * Constructor, second phase. |
|
132 */ |
|
133 void ConstructL(); |
|
134 |
|
135 protected: // data |
|
136 |
|
137 // Database reference |
|
138 const CMRUtilsCalDbBase& iNormalDb; |
|
139 |
|
140 // Database reference |
|
141 CMRUtilsCalDbBase& iTombsDb; |
|
142 |
|
143 // Uid of entry currently investigated |
|
144 TPtrC8 iCurrentEntryUid; |
|
145 |
|
146 // State of the cleaner object |
|
147 TCleanerState iState; |
|
148 |
|
149 // Time criterion for cleanup |
|
150 TTime iTimeLimitUtc; |
|
151 |
|
152 // Idle cleaner, own |
|
153 CIdle* iIdleCleaner; |
|
154 |
|
155 // Iterator for tombstone db, own |
|
156 CCalIter* iTombsEntryIterator; |
|
157 }; |
|
158 |
|
159 #endif // __CMRUTILSGRAVEYARDCLEANER_H__ |
|
160 |
|
161 // End of File |