22 |
22 |
23 #include "CalenSvrBootManager.h" |
23 #include "CalenSvrBootManager.h" |
24 |
24 |
25 #include "CalenServer.h" |
25 #include "CalenServer.h" |
26 #include <calenglobaldata.h> |
26 #include <calenglobaldata.h> |
|
27 #include <calcalendarinfo.h> |
|
28 #include <calcalendariterator.h> |
27 |
29 |
28 #include <featmgr.h> |
30 #include <featmgr.h> |
29 |
31 |
30 // LOCAL CONSTANTS AND MACROS |
32 // LOCAL CONSTANTS AND MACROS |
|
33 const TInt KBuffLength = 8; |
|
34 |
|
35 _LIT( KCalendarDatabaseFilePath, "c:calendar" ); |
31 |
36 |
32 enum TCalenSvrBootManagerPanic |
37 enum TCalenSvrBootManagerPanic |
33 { |
38 { |
34 EPanicInvalidState, |
39 EPanicInvalidState, |
35 EPanicRunError, |
40 EPanicRunError, |
187 } |
192 } |
188 |
193 |
189 CleanupReleasePushL( *gData ); |
194 CleanupReleasePushL( *gData ); |
190 gData->CalSessionL(); |
195 gData->CalSessionL(); |
191 CleanupStack::PopAndDestroy( gData ); |
196 CleanupStack::PopAndDestroy( gData ); |
|
197 iState = EStateDeleteDeadCalendars; |
|
198 CompleteSelf(); |
|
199 } |
|
200 break; |
|
201 case EStateDeleteDeadCalendars: |
|
202 { |
|
203 RemoveDeadCalendarsL(); |
192 iState = EStateReady; |
204 iState = EStateReady; |
193 CompleteSelf(); |
205 CompleteSelf(); |
194 } |
206 } |
195 break; |
207 break; |
196 |
208 |
261 { |
273 { |
262 TRACE_ENTRY_POINT; |
274 TRACE_ENTRY_POINT; |
263 TRACE_EXIT_POINT; |
275 TRACE_EXIT_POINT; |
264 } |
276 } |
265 |
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CCalenSvrBootManager::RemoveDeadCalendarsL |
|
280 // Remove all the files which are marked as EMarkAsDelete from device's |
|
281 // file system |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CCalenSvrBootManager::RemoveDeadCalendarsL() |
|
285 { |
|
286 TRACE_ENTRY_POINT; |
|
287 TBool softDelete; |
|
288 TBuf8<KBuffLength> keyBuff; |
|
289 |
|
290 // Mark the meta property key as SoftDeleted |
|
291 keyBuff.Zero(); |
|
292 keyBuff.AppendNum(EMarkAsDelete); |
|
293 |
|
294 CCalSession* session = CCalSession::NewL(); |
|
295 CleanupStack::PushL(session); |
|
296 CCalCalendarIterator* calendarIterator = |
|
297 CCalCalendarIterator::NewL(*session); |
|
298 CleanupStack::PushL(calendarIterator); |
|
299 |
|
300 for( CCalCalendarInfo* calendarInfo = calendarIterator->FirstL(); |
|
301 calendarInfo!=NULL;calendarInfo = calendarIterator->NextL()) |
|
302 { |
|
303 CleanupStack::PushL(calendarInfo); |
|
304 softDelete = EFalse; |
|
305 TPckgC<TBool> pkgSoftDelete( softDelete ); |
|
306 TRAPD(err,pkgSoftDelete.Set(calendarInfo->PropertyValueL(keyBuff))); |
|
307 if( KErrNone == err ) |
|
308 { |
|
309 softDelete = pkgSoftDelete(); |
|
310 } |
|
311 if(softDelete && calendarInfo->FileNameL().CompareF(KCalendarDatabaseFilePath) ) |
|
312 { |
|
313 //Delete the calendar except default calendar. |
|
314 TRAP_IGNORE(session->DeleteCalFileL(calendarInfo->FileNameL())); |
|
315 } |
|
316 CleanupStack::PopAndDestroy(calendarInfo); |
|
317 } |
|
318 CleanupStack::PopAndDestroy(calendarIterator); |
|
319 CleanupStack::PopAndDestroy( session ); |
|
320 TRACE_EXIT_POINT; |
|
321 } |
|
322 |
266 // End of File |
323 // End of File |