|
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: |
|
15 * Recent list duplicate cleaner |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
23 #include <logfilterandeventconstants.hrh> |
|
24 #endif |
|
25 #include <logview.h> |
|
26 #include "CLogsClearDuplicates.h" |
|
27 |
|
28 // MODULE DATA STRUCTURES |
|
29 |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CLogsClearDuplicates::NewL |
|
36 // ---------------------------------------------------------------------------- |
|
37 // |
|
38 CLogsClearDuplicates* CLogsClearDuplicates::NewL( RFs& aFsSession ) |
|
39 { |
|
40 CLogsClearDuplicates* self = new (ELeave) CLogsClearDuplicates( aFsSession ); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // CLogsClearDuplicates::CLogsClearDuplicates |
|
49 // ---------------------------------------------------------------------------- |
|
50 // |
|
51 CLogsClearDuplicates::CLogsClearDuplicates( RFs& aFsSession ) : |
|
52 CActive( EPriorityStandard ), |
|
53 iFsSession( aFsSession ) |
|
54 { |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // CLogsClearDuplicates:: |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 void CLogsClearDuplicates::ConstructL() |
|
62 { |
|
63 iLogClient = CLogClient::NewL( iFsSession ); |
|
64 |
|
65 // Initialize database view for log events having "read" flag unset |
|
66 iFlagClearView = CLogViewRecent::NewL( *iLogClient, *this ); |
|
67 iFilterFlagClear = CLogFilter::NewL(); |
|
68 iFilterFlagClear->SetFlags( KLogEventRead ); |
|
69 iFilterFlagClear->SetNullFields( ELogFlagsField ); |
|
70 |
|
71 // Initialize database view for log events having "ALS" flag set |
|
72 iFlagClearViewALS = CLogViewRecent::NewL( *iLogClient, *this ); |
|
73 iFilterFlagClearALS = CLogFilter::NewL(); |
|
74 iFilterFlagClearALS->SetFlags( KLogEventALS ); |
|
75 iClearViewALSIsSet = EFalse; |
|
76 |
|
77 CActiveScheduler::Add( this ); |
|
78 SetFlagClearViewL(); |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CLogsClearDuplicates::~CLogsClearDuplicates |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CLogsClearDuplicates::~CLogsClearDuplicates() |
|
86 { |
|
87 Cancel(); |
|
88 delete iFlagClearView; |
|
89 delete iFilterFlagClear; |
|
90 |
|
91 delete iFlagClearViewALS; |
|
92 delete iFilterFlagClearALS; |
|
93 |
|
94 delete iLogClient; |
|
95 } |
|
96 |
|
97 // ---------------------------------------------------------------------------- |
|
98 // CLogsClearDuplicates::DoCancel |
|
99 // ---------------------------------------------------------------------------- |
|
100 // |
|
101 void CLogsClearDuplicates::DoCancel() |
|
102 { |
|
103 if( iFlagClearView ) |
|
104 { |
|
105 iFlagClearView->Cancel(); |
|
106 } |
|
107 |
|
108 if( iFlagClearViewALS ) |
|
109 { |
|
110 iFlagClearViewALS->Cancel(); |
|
111 } |
|
112 |
|
113 if( iLogClient ) |
|
114 { |
|
115 iLogClient->Cancel(); |
|
116 } |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CLogsClearDuplicates::RunL |
|
121 // ---------------------------------------------------------------------------- |
|
122 // |
|
123 void CLogsClearDuplicates::RunL() |
|
124 { |
|
125 // If iClearViewALSIsSet is false, the asynchronous request made in |
|
126 // SetFlagClearViewL is finished. So we can proceed to call SetFlagClearViewALSL. |
|
127 if ( !iClearViewALSIsSet ) |
|
128 { |
|
129 SetFlagClearViewALSL(); |
|
130 } |
|
131 |
|
132 } |
|
133 |
|
134 // ---------------------------------------------------------------------------- |
|
135 // CLogsClearDuplicates::SetFlagClearViewALSL |
|
136 // |
|
137 // Note: this will only get called if CLogsClearDuplicates::SetFlagClearViewL() |
|
138 // calls SetActive (there are unread events in the view) |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 void CLogsClearDuplicates::SetFlagClearViewALSL() |
|
142 { |
|
143 Cancel(); |
|
144 |
|
145 if( iFlagClearViewALS->SetRecentListL( ELogsMissedModel, *iFilterFlagClearALS, iStatus )) |
|
146 { |
|
147 iClearViewALSIsSet = ETrue; // Set to ETrue, so RunL won't call this again |
|
148 SetActive(); |
|
149 } |
|
150 } |
|
151 |
|
152 // ---------------------------------------------------------------------------- |
|
153 // CLogsClearDuplicates::SetFlagClearViewL |
|
154 // ---------------------------------------------------------------------------- |
|
155 // |
|
156 void CLogsClearDuplicates::SetFlagClearViewL() |
|
157 { |
|
158 Cancel(); |
|
159 |
|
160 if( iFlagClearView->SetRecentListL( ELogsMissedModel, *iFilterFlagClear, iStatus ) ) |
|
161 { |
|
162 SetActive(); |
|
163 } |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------------------------------- |
|
167 // CLogsClearDuplicates::HandleLogViewChangeEventAddedL |
|
168 // ---------------------------------------------------------------------------- |
|
169 // |
|
170 void CLogsClearDuplicates::HandleLogViewChangeEventAddedL( |
|
171 TLogId /*aId*/, |
|
172 TInt /*aViewIndex*/, |
|
173 TInt /*aChangeIndex*/, |
|
174 TInt aTotalChangeCount ) |
|
175 { |
|
176 if( aTotalChangeCount && !IsActive() ) |
|
177 { |
|
178 iClearViewALSIsSet = EFalse; |
|
179 SetFlagClearViewL(); |
|
180 } |
|
181 } |
|
182 |
|
183 // ---------------------------------------------------------------------------- |
|
184 // CLogsClearDuplicates::HandleLogViewChangeEventChangedL |
|
185 // ---------------------------------------------------------------------------- |
|
186 // |
|
187 void CLogsClearDuplicates::HandleLogViewChangeEventChangedL( |
|
188 TLogId /*aId*/, |
|
189 TInt /*aViewIndex*/, |
|
190 TInt /*aChangeIndex*/, |
|
191 TInt /*aTotalChangeCount*/ ) // no need to do anything in change notification |
|
192 { |
|
193 } |
|
194 |
|
195 // ---------------------------------------------------------------------------- |
|
196 // CLogsClearDuplicates::HandleLogViewChangeEventDeletedL |
|
197 // ---------------------------------------------------------------------------- |
|
198 // |
|
199 void CLogsClearDuplicates::HandleLogViewChangeEventDeletedL( |
|
200 TLogId /*aId*/, |
|
201 TInt /*aViewIndex*/, |
|
202 TInt /*aChangeIndex*/, |
|
203 TInt /*aTotalChangeCount*/ ) // no need to do anything in delete notification |
|
204 { |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // CLogsClearDuplicates::ClearDuplicatesL |
|
209 // ---------------------------------------------------------------------------- |
|
210 // |
|
211 void CLogsClearDuplicates::ClearDuplicatesL( |
|
212 TBool aDuplicates, |
|
213 CLogViewRecent* aView ) |
|
214 { |
|
215 // aDuplicates is true if there are events in missed view that have duplicates. |
|
216 // Clear all duplicates from provided CLogViewRecent |
|
217 if( aDuplicates && aView ) |
|
218 { |
|
219 aView->ClearDuplicatesL(); |
|
220 } |
|
221 |
|
222 |
|
223 // First flag all "not read" events to the secondary number (ALS) as "read". |
|
224 // This has to be done separately cause just calling |
|
225 // iFlagClearView->SetFlagsL(KLogEventRead) below would overwrite the ALS flag. |
|
226 if( aView && iFlagClearViewALS->CountL() ) |
|
227 { |
|
228 iFlagClearViewALS->SetFlagsL( KLogEventRead | KLogEventALS ); |
|
229 } |
|
230 |
|
231 //Then flag all remaining "not read" events to "read" status. The "read" flag needs to be set |
|
232 //to prevent the already processd duplicates to show up later again. This is |
|
233 //because an existing event turn to be a duplicate again if a new similar event |
|
234 //is later inserted to db. So ClearDuplicatesL() just is not enough for this. |
|
235 if( aView && iFlagClearView->CountL() ) |
|
236 { |
|
237 iFlagClearView->SetFlagsL( KLogEventRead ); |
|
238 } |
|
239 |
|
240 // |
|
241 iClearViewALSIsSet = EFalse; |
|
242 |
|
243 } |