66
|
1 |
/*
|
|
2 |
* Copyright (c) 2004 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 asynchronus methods for the multistep boot sequence.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
//debug
|
|
21 |
#include "calendarui_debug.h"
|
|
22 |
|
|
23 |
#include "CalenSvrBootManager.h"
|
|
24 |
|
|
25 |
#include "CalenServer.h"
|
|
26 |
#include <calenglobaldata.h>
|
|
27 |
#include <calcalendarinfo.h>
|
|
28 |
#include <calcalendariterator.h>
|
|
29 |
|
|
30 |
#include <featmgr.h>
|
|
31 |
|
|
32 |
// LOCAL CONSTANTS AND MACROS
|
|
33 |
const TInt KBuffLength = 8;
|
|
34 |
|
|
35 |
_LIT( KCalendarDatabaseFilePath, "c:calendar" );
|
|
36 |
|
|
37 |
enum TCalenSvrBootManagerPanic
|
|
38 |
{
|
|
39 |
EPanicInvalidState,
|
|
40 |
EPanicRunError,
|
|
41 |
EPanicCorruptedObserverDll,
|
|
42 |
EPanicIncorrectObserverUID
|
|
43 |
};
|
|
44 |
|
|
45 |
static void Panic(TInt aReason)
|
|
46 |
{
|
|
47 |
TRACE_ENTRY_POINT;
|
|
48 |
|
|
49 |
_LIT(KCategory, "CCalenServerBootHandler");
|
|
50 |
User::Panic(KCategory, aReason);
|
|
51 |
|
|
52 |
TRACE_EXIT_POINT;
|
|
53 |
};
|
|
54 |
|
|
55 |
|
|
56 |
// CLASS METHOD DECLARATIONS
|
|
57 |
|
|
58 |
// -----------------------------------------------------------------------------
|
|
59 |
// ?classname::?member_function
|
|
60 |
// ?implementation_description
|
|
61 |
// (other items were commented in a header).
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
CCalenSvrBootManager* CCalenSvrBootManager::NewL(CCalenServer& aServer)
|
|
65 |
{
|
|
66 |
TRACE_ENTRY_POINT;
|
|
67 |
|
|
68 |
CCalenSvrBootManager* self = new( ELeave )CCalenSvrBootManager( aServer );
|
|
69 |
CleanupStack::PushL(self);
|
|
70 |
self->ConstructL();
|
|
71 |
CleanupStack::Pop(self);
|
|
72 |
|
|
73 |
TRACE_EXIT_POINT;
|
|
74 |
return self;
|
|
75 |
}
|
|
76 |
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
// ?classname::?member_function
|
|
79 |
// ?implementation_description
|
|
80 |
// (other items were commented in a header).
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
CCalenSvrBootManager::CCalenSvrBootManager(CCalenServer& aServer)
|
|
84 |
: CActive(0), iState(EStateInit), iServer(aServer)
|
|
85 |
{
|
|
86 |
TRACE_ENTRY_POINT;
|
|
87 |
|
|
88 |
CActiveScheduler::Add(this);
|
|
89 |
|
|
90 |
TRACE_EXIT_POINT;
|
|
91 |
}
|
|
92 |
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
// ?classname::?member_function
|
|
95 |
// ?implementation_description
|
|
96 |
// (other items were commented in a header).
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
void CCalenSvrBootManager::ConstructL(void)
|
|
100 |
{
|
|
101 |
TRACE_ENTRY_POINT;
|
|
102 |
|
|
103 |
Start();
|
|
104 |
|
|
105 |
TRACE_EXIT_POINT;
|
|
106 |
}
|
|
107 |
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
// ?classname::?member_function
|
|
110 |
// ?implementation_description
|
|
111 |
// (other items were commented in a header).
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
void CCalenSvrBootManager::Start()
|
|
115 |
{
|
|
116 |
TRACE_ENTRY_POINT;
|
|
117 |
|
|
118 |
__ASSERT_ALWAYS(!IsActive(), User::Invariant());
|
|
119 |
iState = EStateCreateAgendaFile;
|
|
120 |
CompleteSelf();
|
|
121 |
|
|
122 |
TRACE_EXIT_POINT;
|
|
123 |
}
|
|
124 |
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
// ?classname::?member_function
|
|
127 |
// ?implementation_description
|
|
128 |
// (other items were commented in a header).
|
|
129 |
// -----------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
CCalenSvrBootManager::~CCalenSvrBootManager()
|
|
132 |
{
|
|
133 |
TRACE_ENTRY_POINT;
|
|
134 |
|
|
135 |
Cancel(); // DoCancel destroy everything
|
|
136 |
|
|
137 |
TRACE_EXIT_POINT;
|
|
138 |
}
|
|
139 |
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
// ?classname::?member_function
|
|
142 |
// ?implementation_description
|
|
143 |
// (other items were commented in a header).
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void CCalenSvrBootManager::DoCancel()
|
|
147 |
{
|
|
148 |
TRACE_ENTRY_POINT;
|
|
149 |
|
|
150 |
iState = EStateInit;
|
|
151 |
|
|
152 |
TRACE_EXIT_POINT;
|
|
153 |
}
|
|
154 |
|
|
155 |
// -----------------------------------------------------------------------------
|
|
156 |
// ?classname::?member_function
|
|
157 |
// ?implementation_description
|
|
158 |
// (other items were commented in a header).
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
//
|
|
161 |
TInt CCalenSvrBootManager::RunError(TInt /*aError*/)
|
|
162 |
{
|
|
163 |
TRACE_ENTRY_POINT;
|
|
164 |
|
|
165 |
// if database is corrupted or we run in to other troubles, we ignore them.
|
|
166 |
iState = EStateReady;
|
|
167 |
CompleteSelf();
|
|
168 |
|
|
169 |
TRACE_EXIT_POINT;
|
|
170 |
return KErrNone;
|
|
171 |
}
|
|
172 |
|
|
173 |
// -----------------------------------------------------------------------------
|
|
174 |
// ?classname::?member_function
|
|
175 |
// ?implementation_description
|
|
176 |
// (other items were commented in a header).
|
|
177 |
// -----------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
void CCalenSvrBootManager::RunL()
|
|
180 |
{
|
|
181 |
TRACE_ENTRY_POINT;
|
|
182 |
|
|
183 |
switch (iState)
|
|
184 |
{
|
|
185 |
case EStateCreateAgendaFile:
|
|
186 |
{
|
|
187 |
CCalenGlobalData* gData = CCalenGlobalData::Instance();
|
|
188 |
if ( !gData )
|
|
189 |
{
|
|
190 |
// Server doesn't need context change observer.
|
|
191 |
gData = CCalenGlobalData::NewL( *this, NULL );
|
|
192 |
}
|
|
193 |
|
|
194 |
CleanupReleasePushL( *gData );
|
|
195 |
gData->CalSessionL();
|
|
196 |
CleanupStack::PopAndDestroy( gData );
|
|
197 |
iState = EStateDeleteDeadCalendars;
|
|
198 |
CompleteSelf();
|
|
199 |
}
|
|
200 |
break;
|
|
201 |
case EStateDeleteDeadCalendars:
|
|
202 |
{
|
|
203 |
RemoveDeadCalendarsL();
|
|
204 |
iState = EStateReady;
|
|
205 |
CompleteSelf();
|
|
206 |
}
|
|
207 |
break;
|
|
208 |
|
|
209 |
case EStateReady:
|
|
210 |
iServer.BootReadyL();
|
|
211 |
break;
|
|
212 |
|
|
213 |
default:
|
|
214 |
Panic(EPanicInvalidState);
|
|
215 |
break;
|
|
216 |
}
|
|
217 |
|
|
218 |
TRACE_EXIT_POINT;
|
|
219 |
}
|
|
220 |
|
|
221 |
// -----------------------------------------------------------------------------
|
|
222 |
// ?classname::?member_function
|
|
223 |
// ?implementation_description
|
|
224 |
// (other items were commented in a header).
|
|
225 |
// -----------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
void CCalenSvrBootManager::CompleteSelf()
|
|
228 |
{
|
|
229 |
TRACE_ENTRY_POINT;
|
|
230 |
|
|
231 |
TRequestStatus* pStat = &iStatus;
|
|
232 |
User::RequestComplete(pStat, KErrNone);
|
|
233 |
SetActive();
|
|
234 |
|
|
235 |
TRACE_EXIT_POINT;
|
|
236 |
}
|
|
237 |
|
|
238 |
// -----------------------------------------------------------------------------
|
|
239 |
// CCalenSvrBootManager::Completed
|
|
240 |
// Unused but needed as CCalenSvrBootManager needs
|
|
241 |
// be derived from MCalProgressCallBack to call
|
|
242 |
// CCalenGlobalData::NewL()
|
|
243 |
// -----------------------------------------------------------------------------
|
|
244 |
//
|
|
245 |
void CCalenSvrBootManager::Completed(TInt /*aError*/)
|
|
246 |
{
|
|
247 |
}
|
|
248 |
|
|
249 |
// -----------------------------------------------------------------------------
|
|
250 |
// CCalenSvrBootManager::NotifyProgress()
|
|
251 |
// Unused but needed as CCalenSvrBootManager needs
|
|
252 |
// be derived from MCalProgressCallBack to call
|
|
253 |
// CCalenGlobalData::NewL()
|
|
254 |
// -----------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
TBool CCalenSvrBootManager::NotifyProgress()
|
|
257 |
{
|
|
258 |
TRACE_ENTRY_POINT;
|
|
259 |
|
|
260 |
return EFalse;
|
|
261 |
|
|
262 |
TRACE_EXIT_POINT;
|
|
263 |
}
|
|
264 |
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
// CCalenSvrBootManager::Progress
|
|
267 |
// Unused but needed as CCalenSvrBootManager needs
|
|
268 |
// be derived from MCalProgressCallBack to call
|
|
269 |
// CCalenGlobalData::NewL()
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
//
|
|
272 |
void CCalenSvrBootManager::Progress(TInt /*aPercentageCompleted*/)
|
|
273 |
{
|
|
274 |
TRACE_ENTRY_POINT;
|
|
275 |
TRACE_EXIT_POINT;
|
|
276 |
}
|
|
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 |
|
|
323 |
// End of File
|