1 /* |
|
2 * Copyright (c) 2004-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: Implementation of the application engine component interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <EPos_CPosLandmarkDatabase.h> |
|
21 |
|
22 #include "LmRefApp.hrh" |
|
23 #include "LandmarksApplicationEngine.h" |
|
24 #include "LandmarksCommonData.h" |
|
25 #include "LandmarksEngine.h" |
|
26 #include "LandmarksCategoriesEngine.h" |
|
27 #include "LandmarksDbEventHandler.h" |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CLandmarksApplicationEngine::CLandmarksApplicationEngine |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CLandmarksApplicationEngine::CLandmarksApplicationEngine() |
|
38 { |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CLandmarksApplicationEngine::::ConstructL |
|
43 // Symbian 2nd phase constructor can leave. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void CLandmarksApplicationEngine::ConstructL() |
|
47 { |
|
48 iDb = CPosLandmarkDatabase::OpenL(); |
|
49 iLandmarksEngine = CLandmarksEngine::NewL(*iDb); |
|
50 iCategoriesEngine = CLandmarksCategoriesEngine::NewL(*iDb); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CLandmarksApplicationEngine::NewL |
|
55 // Two-phased constructor. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CLandmarksApplicationEngine* CLandmarksApplicationEngine::NewL() |
|
59 { |
|
60 CLandmarksApplicationEngine* self = |
|
61 new (ELeave) CLandmarksApplicationEngine(); |
|
62 CleanupStack::PushL(self); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop(self); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CLandmarksApplicationEngine::~CLandmarksApplicationEngine() |
|
72 { |
|
73 delete iLandmarksEngine; |
|
74 delete iCategoriesEngine; |
|
75 delete iDbEventHandler; |
|
76 delete iDb; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CLandmarksApplicationEngine::NotifyViewActivated |
|
81 // The engine that corresponds to an active view must have higher priority than |
|
82 // engines corresponding to deactivated views. |
|
83 // (other items were commented in a header). |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CLandmarksApplicationEngine::NotifyViewActivated( |
|
87 TUid aViewId, |
|
88 TBool aIsActive) |
|
89 { |
|
90 if (aViewId.iUid == ELandmarksViewId) |
|
91 { |
|
92 if (aIsActive) |
|
93 { |
|
94 iLandmarksEngine->SetPrio(CActive::EPriorityStandard); |
|
95 } |
|
96 else |
|
97 { |
|
98 iLandmarksEngine->SetPrio(CActive::EPriorityLow); |
|
99 } |
|
100 } |
|
101 else if (aViewId.iUid == ELandmarksCategoriesViewId) |
|
102 { |
|
103 if (aIsActive) |
|
104 { |
|
105 iCategoriesEngine->SetPrio(CActive::EPriorityStandard); |
|
106 } |
|
107 else |
|
108 { |
|
109 iCategoriesEngine->SetPrio(CActive::EPriorityLow); |
|
110 } |
|
111 } |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CLandmarksApplicationEngine::StartInitializeDbIfNecessaryL |
|
116 // |
|
117 // (other items were commented in a header). |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 TBool CLandmarksApplicationEngine::StartInitializeDbIfNecessaryL( |
|
121 MLandmarksOperationObserver* aObserver) |
|
122 { |
|
123 return iLandmarksEngine->StartInitializeDbIfNecessaryL(aObserver); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CLandmarksApplicationEngine::AddDbObserverL |
|
128 // |
|
129 // (other items were commented in a header). |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CLandmarksApplicationEngine::AddDbObserverL( |
|
133 MLandmarksDbObserver* aObserver) |
|
134 { |
|
135 if (!iDbEventHandler) |
|
136 { |
|
137 iDbEventHandler = new (ELeave) CLandmarksDbEventHandler(*iDb); |
|
138 } |
|
139 iDbEventHandler->AddObserverL(aObserver); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CLandmarksApplicationEngine::LandmarkLC |
|
144 // |
|
145 // (other items were commented in a header). |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 CPosLandmark* CLandmarksApplicationEngine::LandmarkLC(TPosLmItemId aItemId) |
|
149 { |
|
150 return iDb->ReadLandmarkLC(aItemId); |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CLandmarksApplicationEngine::CommitLandmarkL |
|
155 // |
|
156 // (other items were commented in a header). |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CLandmarksApplicationEngine::CommitLandmarkL( |
|
160 const CPosLandmark& aLandmark) |
|
161 { |
|
162 // We need to cancel any search/read operation in any view engine. |
|
163 // Otherwise database will be locked. |
|
164 iLandmarksEngine->Cancel(); |
|
165 iCategoriesEngine->Cancel(); |
|
166 |
|
167 iLandmarksEngine->CommitLandmarkL(aLandmark); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CLandmarksApplicationEngine::DeleteLandmarkL |
|
172 // |
|
173 // (other items were commented in a header). |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void CLandmarksApplicationEngine::DeleteLandmarkL(TPosLmItemId aItemId) |
|
177 { |
|
178 // We need to cancel any search/read operation in any view engine. |
|
179 // Otherwise database will be locked. |
|
180 iLandmarksEngine->Cancel(); |
|
181 iCategoriesEngine->Cancel(); |
|
182 |
|
183 iLandmarksEngine->DeleteLandmarkL(aItemId); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CLandmarksApplicationEngine::AddLandmarkL |
|
188 // |
|
189 // (other items were commented in a header). |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CLandmarksApplicationEngine::AddLandmarkL(CPosLandmark& aLandmark) |
|
193 { |
|
194 // We need to cancel any search/read operation in any view engine. |
|
195 // Otherwise database will be locked. |
|
196 iLandmarksEngine->Cancel(); |
|
197 iCategoriesEngine->Cancel(); |
|
198 |
|
199 iLandmarksEngine->AddLandmarkL(aLandmark); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CLandmarksApplicationEngine::StartSearchingLandmarksL |
|
204 // |
|
205 // (other items were commented in a header). |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void CLandmarksApplicationEngine::StartSearchingLandmarksL( |
|
209 MLandmarksOperationObserver* aObserver) |
|
210 { |
|
211 iLandmarksEngine->StartSearchingLandmarksL(aObserver); |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // CLandmarksApplicationEngine::StartSearchingLandmarksL |
|
216 // |
|
217 // (other items were commented in a header). |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 void CLandmarksApplicationEngine::StartSearchingLandmarksL( |
|
221 const TDesC& aSearchPattern, |
|
222 TBool aSearchOnlyInPreviousMatches, |
|
223 MLandmarksOperationObserver* aObserver) |
|
224 { |
|
225 iLandmarksEngine->StartSearchingLandmarksL( |
|
226 aSearchPattern, |
|
227 aSearchOnlyInPreviousMatches, |
|
228 aObserver); |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CLandmarksApplicationEngine::FetchLandmarkSearchResultL |
|
233 // |
|
234 // (other items were commented in a header). |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 RArray<TPosLmItemId>* CLandmarksApplicationEngine::FetchLandmarkSearchResult() |
|
238 { |
|
239 return iLandmarksEngine->FetchSearchResult(); |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CLandmarksApplicationEngine::StartReadingLandmarksL |
|
244 // |
|
245 // (other items were commented in a header). |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 void CLandmarksApplicationEngine::StartReadingLandmarksL( |
|
249 TInt aNrOfItemsToReadPerBundle, |
|
250 MLandmarksOperationObserver* aObserver) |
|
251 { |
|
252 iLandmarksEngine->StartReadingLandmarksL( |
|
253 aNrOfItemsToReadPerBundle, |
|
254 aObserver); |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CLandmarksApplicationEngine::FetchLandmarksLC |
|
259 // |
|
260 // (other items were commented in a header). |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 CArrayPtr<CPosLandmark>* CLandmarksApplicationEngine::FetchLandmarksLC() |
|
264 { |
|
265 return iLandmarksEngine->FetchLandmarksLC(); |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CLandmarksApplicationEngine::CategoryLC |
|
270 // |
|
271 // (other items were commented in a header). |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 CPosLandmarkCategory* CLandmarksApplicationEngine::CategoryLC( |
|
275 TPosLmItemId aItemId) |
|
276 { |
|
277 return iCategoriesEngine->CategoryLC(aItemId); |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CLandmarksApplicationEngine::DeleteCategoryL |
|
282 // |
|
283 // (other items were commented in a header). |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 void CLandmarksApplicationEngine::DeleteCategoryL(TPosLmItemId aItemId) |
|
287 { |
|
288 // We need to cancel any search/read operation in any view engine. |
|
289 // Otherwise database will be locked. |
|
290 iLandmarksEngine->Cancel(); |
|
291 iCategoriesEngine->Cancel(); |
|
292 |
|
293 iCategoriesEngine->DeleteCategoryL(aItemId); |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CLandmarksApplicationEngine::UpdateCategoryL |
|
298 // |
|
299 // (other items were commented in a header). |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 void CLandmarksApplicationEngine::UpdateCategoryL( |
|
303 const CPosLandmarkCategory& aCategory) |
|
304 { |
|
305 // We need to cancel any search/read operation in any view engine. |
|
306 // Otherwise database will be locked. |
|
307 iLandmarksEngine->Cancel(); |
|
308 iCategoriesEngine->Cancel(); |
|
309 |
|
310 iCategoriesEngine->UpdateCategoryL(aCategory); |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CLandmarksApplicationEngine::AddCategoryL |
|
315 // |
|
316 // (other items were commented in a header). |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 void CLandmarksApplicationEngine::AddCategoryL(CPosLandmarkCategory& aCategory) |
|
320 { |
|
321 // We need to cancel any search/read operation in any view engine. |
|
322 // Otherwise database will be locked. |
|
323 iLandmarksEngine->Cancel(); |
|
324 iCategoriesEngine->Cancel(); |
|
325 |
|
326 iCategoriesEngine->AddCategoryL(aCategory); |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // CLandmarksApplicationEngine::StartSearchingCategoriesL |
|
331 // |
|
332 // (other items were commented in a header). |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void CLandmarksApplicationEngine::StartSearchingCategoriesL( |
|
336 const TDesC& aSearchPattern, |
|
337 TBool aSearchOnlyInPreviousMatches, |
|
338 MLandmarksOperationObserver* aObserver) |
|
339 { |
|
340 iCategoriesEngine->StartSearchingCategoriesL( |
|
341 aSearchPattern, |
|
342 aSearchOnlyInPreviousMatches, |
|
343 aObserver); |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CLandmarksApplicationEngine::StartSearchingCategoriesL |
|
348 // |
|
349 // (other items were commented in a header). |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 void CLandmarksApplicationEngine::StartSearchingCategoriesL( |
|
353 MLandmarksOperationObserver* aObserver) |
|
354 { |
|
355 iCategoriesEngine->StartSearchingCategoriesL(aObserver); |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // CLandmarksApplicationEngine::FetchCategorySearchResult |
|
360 // |
|
361 // (other items were commented in a header). |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 RArray<TPosLmItemId>* CLandmarksApplicationEngine::FetchCategorySearchResult() |
|
365 { |
|
366 return iCategoriesEngine->FetchSearchResult(); |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // CLandmarksApplicationEngine::StartReadingCategoriesL |
|
371 // |
|
372 // (other items were commented in a header). |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 void CLandmarksApplicationEngine::StartReadingCategoriesL( |
|
376 TInt aNrOfItemsToReadPerBundle, |
|
377 MLandmarksOperationObserver* aObserver) |
|
378 { |
|
379 iCategoriesEngine->StartReadingCategoriesL( |
|
380 aNrOfItemsToReadPerBundle, aObserver); |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // CLandmarksApplicationEngine::FetchCategoriesLC |
|
385 // |
|
386 // (other items were commented in a header). |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 CArrayPtr<CPosLandmarkCategory>* CLandmarksApplicationEngine::FetchCategoriesLC() |
|
390 { |
|
391 return iCategoriesEngine->FetchCategoriesLC(); |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // CLandmarksApplicationEngine::CategoriesL |
|
396 // |
|
397 // (other items were commented in a header). |
|
398 // ----------------------------------------------------------------------------- |
|
399 // |
|
400 CArrayPtr<CPosLandmarkCategory>* CLandmarksApplicationEngine::CategoriesL() |
|
401 { |
|
402 return iCategoriesEngine->CategoriesL(); |
|
403 } |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 HBufC* CLandmarksApplicationEngine::DatabaseUriLC() |
|
409 { |
|
410 return iDb->DatabaseUriLC(); |
|
411 } |
|
412 |
|
413 |
|