5
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2006 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 the License "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: CLandmarkService class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef __CLANDMARKSERVICE_H__
|
|
21 |
#define __CLANDMARKSERVICE_H__
|
|
22 |
|
|
23 |
#ifdef _DEBUG
|
|
24 |
#include <flogger.h>
|
|
25 |
#endif
|
|
26 |
|
|
27 |
// INCLUDES
|
|
28 |
#include <e32base.h>
|
|
29 |
#include <e32cmn.h>
|
|
30 |
#include <badesca.h>
|
|
31 |
|
|
32 |
//FORWARD DECLARARTIONS
|
|
33 |
class CLandmarkManageHandlers;
|
|
34 |
class MLandmarkObserver;
|
|
35 |
class CLandmarkFilter;
|
|
36 |
class CPosLandmarkParser;
|
|
37 |
class CPosLandmarkEncoder;
|
|
38 |
class CPosLmItemIterator;
|
|
39 |
class CPosLmDatabaseManager;
|
|
40 |
class CPosLandmark;
|
|
41 |
class CPosLandmarkCategory;
|
|
42 |
class TPosLmDatabaseSettings;
|
|
43 |
class CLandmarkManageObjects;
|
|
44 |
|
|
45 |
/**
|
|
46 |
* CLandmarkService
|
|
47 |
* This class has the core implementation. The member functions of this class
|
|
48 |
* call the native landmarks api's to perform the necessary operations. This class
|
|
49 |
* also owns the garbage collector which takes care of active objects associated
|
|
50 |
* with async requests. It also owns the CLandmarkManageHandlers object that manages
|
|
51 |
* the handles to open databases. The interface class calls the appropriate member
|
|
52 |
* functions of this class to perform the required operation.
|
|
53 |
*/
|
|
54 |
// CLASS DECLARATION
|
|
55 |
NONSHARABLE_CLASS(CLandmarkService): public CBase
|
|
56 |
{
|
|
57 |
public:
|
|
58 |
/**
|
|
59 |
* TPosItem
|
|
60 |
* Specifies whether the id passed is a landmark id or a category id.
|
|
61 |
*/
|
|
62 |
enum TPosItem
|
|
63 |
{
|
|
64 |
ECategory = 0 /**<
|
|
65 |
Item is a landmark category id. */,
|
|
66 |
ELandmark /**<
|
|
67 |
Item is a landmark id. */,
|
|
68 |
};
|
|
69 |
/**
|
|
70 |
* TDatabaseType
|
|
71 |
* Specifies whether the database is local or remote.
|
|
72 |
*/
|
|
73 |
enum TDatabaseType
|
|
74 |
{
|
|
75 |
ELocalDatabase = 0 /**<
|
|
76 |
database is a local. */,
|
|
77 |
ERemoteDatabase /**<
|
|
78 |
database is remote. */,
|
|
79 |
};
|
|
80 |
|
|
81 |
public: // New methods
|
|
82 |
|
|
83 |
/**
|
|
84 |
* NewL.
|
|
85 |
* Two-phased constructor.
|
|
86 |
* Create a CLandmarkService object.
|
|
87 |
* @return A pointer to the created instance of CLandmarkService.
|
|
88 |
*/
|
|
89 |
IMPORT_C static CLandmarkService* NewL();
|
|
90 |
|
|
91 |
/**
|
|
92 |
* NewLC.
|
|
93 |
* Two-phased constructor.
|
|
94 |
* Create a CLandmarkService object.
|
|
95 |
* @return A pointer to the created instance of CLandmarkService.
|
|
96 |
*/
|
|
97 |
IMPORT_C static CLandmarkService* NewLC();
|
|
98 |
|
|
99 |
/**
|
|
100 |
* ~CLandmarkService
|
|
101 |
* Destructor.
|
|
102 |
*/
|
|
103 |
~CLandmarkService();
|
|
104 |
|
|
105 |
public: // Functions to retrieve data members
|
|
106 |
|
|
107 |
/**
|
|
108 |
* ImportL.
|
|
109 |
* Imports landmarks to the requested database.
|
|
110 |
* @param aIterator A pointer reference to the list of imported landmarks. User
|
|
111 |
* owns the iterator.
|
|
112 |
* @param aLandmarkParser The instance of CPosLandmarkParser that
|
|
113 |
* will parse the input landmark file.
|
|
114 |
* @param aDatabaseUri The URI of the database to which the parsed landmarks
|
|
115 |
* will be imported.
|
|
116 |
*/
|
|
117 |
IMPORT_C void ImportL( CPosLmItemIterator*& aIterator,
|
|
118 |
CPosLandmarkParser& aLandmarkParser,
|
|
119 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
120 |
|
|
121 |
/**
|
|
122 |
* ExportL.
|
|
123 |
* Export a set of landmarks from the requested database to a file.
|
|
124 |
* @param aLandmarkEncoder A pointer to a landmark encoder object.
|
|
125 |
* @param aLandmarkIdArray The array of landmark ids which should be exported.
|
|
126 |
* @param aDatabaseUri The URI of the database from which the landmarks will
|
|
127 |
* be exported.
|
|
128 |
*/
|
|
129 |
IMPORT_C void ExportL( CPosLandmarkEncoder& aLandmarkEncoder,
|
|
130 |
const RArray<TPosLmItemId>& aLandmarkIdArray,
|
|
131 |
const TDesC& aDatabaseUri = KNullDesC ) const;
|
|
132 |
|
|
133 |
/**
|
|
134 |
* GetListL.
|
|
135 |
* Gets a list of landmarks/landmark categories from the requested database synchronously.
|
|
136 |
* @param aIterator A pointer reference to the list of retrieved landmarks/landmark
|
|
137 |
* categories. User owns the iterator.
|
|
138 |
* @param aFilter The filter to be used for searching landmarks/landmark categories
|
|
139 |
* in database.
|
|
140 |
* @param aDatabaseUri The URI of the database from which landmarks/lanmdark categories
|
|
141 |
* should be fetched.
|
|
142 |
*/
|
|
143 |
IMPORT_C void GetListL ( CPosLmItemIterator*& aIterator,
|
|
144 |
CLandmarkFilter& aFilter, const TDesC& aDatabaseUri = KNullDesC ) const;
|
|
145 |
|
|
146 |
/**
|
|
147 |
* GetListL.
|
|
148 |
* Gets a list of landmark databases.
|
|
149 |
* @param aDatabaseList A pointer reference to the list of retrieved databases.
|
|
150 |
* User owns allocated list.
|
|
151 |
* @param aProtocol Protocol which matches that of the databases to be retrieved.
|
|
152 |
*/
|
|
153 |
IMPORT_C void GetListL( CDesCArray*& aDatabaseList,
|
|
154 |
const TDesC& aProtocol = KNullDesC ) const;
|
|
155 |
|
|
156 |
/**
|
|
157 |
* GetListL.
|
|
158 |
* Gets a list of landmarks/landmark categories from the requested database asynchronously.
|
|
159 |
* @param aTransactionId The transaction id assigned to this asynchronous request.
|
|
160 |
* @param aFilter The filter to be used for searching landmarks/landmark categories
|
|
161 |
* in database.
|
|
162 |
* @param aDatabaseUri The URI of the database from which landmarks/lanmdark categories
|
|
163 |
* should be fetched.
|
|
164 |
*/
|
|
165 |
IMPORT_C void GetListL( TInt32 aTransactionId,
|
|
166 |
CLandmarkFilter& aFilter, const TDesC& aDatabaseUri = KNullDesC );
|
|
167 |
|
|
168 |
/**
|
|
169 |
* AddItemL.
|
|
170 |
* Adds a new Landmark to the given database.
|
|
171 |
* @param aLandmark CPosLandmark instance to be added to database.
|
|
172 |
* @param aDatabaseUri The URI of the database to which the CPosLandmark
|
|
173 |
* instance should be added.
|
|
174 |
*/
|
|
175 |
IMPORT_C TPosLmItemId AddItemL( CPosLandmark& aLandmark,
|
|
176 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
177 |
|
|
178 |
/**
|
|
179 |
* AddItemL.
|
|
180 |
* Adds a new Landmark category to the given database.
|
|
181 |
* @param aCategory CPosLandmarkCategory instance to be added to database.
|
|
182 |
* @param aDatabaseUri The URI of the database to which CPosLandmarkCategory
|
|
183 |
* instance should be added.
|
|
184 |
*/
|
|
185 |
IMPORT_C TPosLmItemId AddItemL( CPosLandmarkCategory& aCategory,
|
|
186 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
187 |
|
|
188 |
/**
|
|
189 |
* AddItemL.
|
|
190 |
* Adds a new database to terminal.
|
|
191 |
* @param aDatabaseUri The URI of the database to be added to terminal.
|
|
192 |
*/
|
|
193 |
IMPORT_C void AddItemL( const TDesC& aDatabaseUri );
|
|
194 |
|
|
195 |
/**
|
|
196 |
* UpdateItemL.
|
|
197 |
* Updates an existing Landmark in the given database.
|
|
198 |
* @param aLandmark CPosLandmark instance to be updated in database.
|
|
199 |
* @param aDatabaseUri The URI of the database in which CPosLandmark
|
|
200 |
* instance should be updated.
|
|
201 |
*/
|
|
202 |
IMPORT_C void UpdateItemL( const CPosLandmark& aLandmark,
|
|
203 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
204 |
|
|
205 |
/**
|
|
206 |
* UpdateItemL.
|
|
207 |
* Updates an existing Landmark category in the given database.
|
|
208 |
* @param aCategory CPosLandmarkCategory instance to be updated in database.
|
|
209 |
* @param aDatabaseUri The URI of the database to which CPosLandmarkCategory
|
|
210 |
* instance should be updated.
|
|
211 |
*/
|
|
212 |
IMPORT_C void UpdateItemL( const CPosLandmarkCategory& aCategory,
|
|
213 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
214 |
|
|
215 |
/**
|
|
216 |
* UpdateItemL.
|
|
217 |
* Updates existing Database Information.
|
|
218 |
* @param aSettings TPosLmDatabaseSettings information to be updated.
|
|
219 |
* @param aDatabaseUri The URI of the database to be updated.
|
|
220 |
*/
|
|
221 |
IMPORT_C void UpdateItemL( TPosLmDatabaseSettings aSettings,
|
|
222 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
223 |
|
|
224 |
/**
|
|
225 |
* LandmarkLC.
|
|
226 |
* Retrieves a Landmark from the database.
|
|
227 |
* @param aLandmarkId Id of the landmark to be retrieved.
|
|
228 |
* @param aDatabaseUri The URI of the database from which the CPosLandmark
|
|
229 |
* instance should be retrieved.
|
|
230 |
* @return A pointer to CPosLandmark instance.
|
|
231 |
*/
|
|
232 |
IMPORT_C CPosLandmark* LandmarkLC( const TPosLmItemId& aLandmarkId,
|
|
233 |
const TDesC& aDatabaseUri = KNullDesC ) const;
|
|
234 |
|
|
235 |
/**
|
|
236 |
* CategoryLC.
|
|
237 |
* Retrieves a Landmark category from the database.
|
|
238 |
* @param aCategoryId Id of the landmark category to be retrieved.
|
|
239 |
* @param aDatabaseUri The URI of the database from which the CPosLandmarkCategory
|
|
240 |
* instance should be retrieved.
|
|
241 |
* @return A pointer to CPosLandmarkCategory instance.
|
|
242 |
*/
|
|
243 |
IMPORT_C CPosLandmarkCategory* CategoryLC( const TPosLmItemId& aCategoryId,
|
|
244 |
const TDesC& aDatabaseUri = KNullDesC ) const;
|
|
245 |
|
|
246 |
/**
|
|
247 |
* RemoveItemL.
|
|
248 |
* Removes a Landmark/Landmark category from given database.
|
|
249 |
* @param aItemId The id of the Landmark/Landmark category to be removed.
|
|
250 |
* @param aItemIsLandmark Whether id passed is a landmark id or a category id.
|
|
251 |
* @param aDatabaseUri The URI of the database from which the
|
|
252 |
* Landmark/Landmark category is to be removed.
|
|
253 |
*/
|
|
254 |
IMPORT_C void RemoveItemL( TPosLmItemId aItemId, TPosItem aItemIsLandmark,
|
|
255 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
256 |
|
|
257 |
/**
|
|
258 |
* RemoveItemL.
|
|
259 |
* Removes the given database.
|
|
260 |
* @param aDatabaseUri The URI of the database to be removed from terminal.
|
|
261 |
*/
|
|
262 |
IMPORT_C void RemoveItemL( const TDesC& aDatabaseUri );
|
|
263 |
|
|
264 |
/**
|
|
265 |
* SetActiveL.
|
|
266 |
* Sets specified database as an active database.
|
|
267 |
* @param aDatabaseUri The URI of the database to be set as an active database.
|
|
268 |
*/
|
|
269 |
IMPORT_C void SetActiveL( const TDesC& aDatabaseUri );
|
|
270 |
|
|
271 |
/**
|
|
272 |
* LinkCategoryToLandmarksL.
|
|
273 |
* Associates a category with a set of landmarks.
|
|
274 |
* @param aCategoryId The id of category.
|
|
275 |
* @param aLandmarkIdArray The array of landmark ids to which the
|
|
276 |
* category is to be associated.
|
|
277 |
* @param aDatabaseUri The URI of the database in which the landmarks and category exist.
|
|
278 |
*/
|
|
279 |
IMPORT_C void LinkCategoryToLandmarksL( TPosLmItemId aCategoryId,
|
|
280 |
RArray< TPosLmItemId >& aLandmarkIdArray,
|
|
281 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
282 |
|
|
283 |
/**
|
|
284 |
* UnlinkCategoryToLandmarksL.
|
|
285 |
* Dissociates a category with a set of landmarks.
|
|
286 |
* @param aCategoryId The id of category.
|
|
287 |
* @param aLandmarkIdArray The array of landmark ids to which the
|
|
288 |
* category is to be dissociated.
|
|
289 |
* @param aDatabaseUri The URI of the database in which the landmarks and category exist.
|
|
290 |
*/
|
|
291 |
IMPORT_C void UnlinkCategoryToLandmarksL( TPosLmItemId aCategoryId,
|
|
292 |
RArray< TPosLmItemId >& aLandmarkIdArray,
|
|
293 |
const TDesC& aDatabaseUri = KNullDesC );
|
|
294 |
|
|
295 |
/**
|
|
296 |
* RegisterObserver.
|
|
297 |
* Registers an observer for Asynchronous call backs.
|
|
298 |
* @param aObserver A pointer to a concrete MLandmarkObserver instance.
|
|
299 |
*/
|
|
300 |
IMPORT_C void RegisterObserver( MLandmarkObserver* aObserver );
|
|
301 |
|
|
302 |
/**
|
|
303 |
* Cancel.
|
|
304 |
* Cancels an ongoing asynchronous request.
|
|
305 |
* @param aTransactionId The transaction id of the asynchronous request.
|
|
306 |
*/
|
|
307 |
IMPORT_C void Cancel( TInt32 aTransactionId ) const;
|
|
308 |
|
|
309 |
/**
|
|
310 |
* GetDefaultDbUri.
|
|
311 |
* Gets the URI of the default database.
|
|
312 |
* @param aDefaultDbUri A reference to the URI of the default database.
|
|
313 |
*/
|
|
314 |
IMPORT_C void GetDefaultDbUriL( TPtrC& aDefaultDbUri ) const;
|
|
315 |
|
|
316 |
private:// helper functions
|
|
317 |
|
|
318 |
/**
|
|
319 |
* GetDbTypeFromUri.
|
|
320 |
* Gets the type of database.
|
|
321 |
* @param aDatabaseUri The URI of the database whose information is queried.
|
|
322 |
* @return Error.
|
|
323 |
*/
|
|
324 |
TDatabaseType GetDbTypeFromUri ( const TDesC& aDbUri ) const;
|
|
325 |
|
|
326 |
private: // Constructors
|
|
327 |
|
|
328 |
/**
|
|
329 |
* ConstructL
|
|
330 |
* 2nd phase constructor.
|
|
331 |
* Perform the second phase construction of a
|
|
332 |
* CLandmarkService object.
|
|
333 |
*/
|
|
334 |
void ConstructL();
|
|
335 |
|
|
336 |
/**
|
|
337 |
* CLandmarkService.
|
|
338 |
* C++ default constructor.
|
|
339 |
*/
|
|
340 |
CLandmarkService();
|
|
341 |
|
|
342 |
private: // Data members
|
|
343 |
|
|
344 |
/**
|
|
345 |
* iManageHandler
|
|
346 |
* CPosLmManageHandler instance.
|
|
347 |
*/
|
|
348 |
CLandmarkManageHandlers* iManageHandler;
|
|
349 |
|
|
350 |
/**
|
|
351 |
* iDatabaseManager
|
|
352 |
* CPosLmDatabaseManager instance.
|
|
353 |
*/
|
|
354 |
CPosLmDatabaseManager* iDatabaseManager;
|
|
355 |
|
|
356 |
/**
|
|
357 |
* iObserver
|
|
358 |
* MLandmarkObserver instance.
|
|
359 |
*/
|
|
360 |
MLandmarkObserver* iObserver;
|
|
361 |
|
|
362 |
/**
|
|
363 |
* iManageObjects
|
|
364 |
* CLandmarkManageObjects instance.
|
|
365 |
*/
|
|
366 |
CLandmarkManageObjects* iManageObjects;
|
|
367 |
|
|
368 |
#ifdef _DEBUG
|
|
369 |
RFileLogger iLog;
|
|
370 |
#endif
|
|
371 |
};
|
|
372 |
|
|
373 |
#endif // __CLANDMARKSERVICE_H__
|
|
374 |
|
|
375 |
// End of File
|
|
376 |
|