2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: CPosLmCategoryManager class
19 #ifndef CPOSLMCATEGORYMANAGER_H
20 #define CPOSLMCATEGORYMANAGER_H
23 #include "EPos_CPosLandmarkDatabase.h"
24 #include "EPos_CPosLandmarkCategory.h"
25 #include "EPos_CPosLmItemIterator.h"
26 #include "EPos_CPosLmOperation.h"
29 * Category management for a landmark database.
31 * A landmark database can contain a number of categories which can be
32 * assigned to the landmarks in the database. A landmark can be associated
33 * with multiple categories, e.g. a landmark can be a "Restaurant" and a "Pub".
34 * Categories also enable filtered searches, e.g. a client could search for
37 * This class contains functions for managing landmark categories. This includes
38 * reading, listing, creating and updating landmark categories.
40 * @p NetworkServices capability is required for remote databases.
42 * @lib eposlandmarks.lib
45 class CPosLmCategoryManager : public CBase
50 * Specifies the sort preference for landmark categories.
52 enum TCategorySortPref
54 ECategorySortOrderNone = 0 /**<
55 Categories not sorted */,
56 ECategorySortOrderNameAscending /**<
57 Sorted ascending by category name. */,
58 ECategorySortOrderNameDescending /**<
59 Sorted descending by category name. */
65 * Two-phased constructor.
67 * The client takes ownership of the category manager.
69 * @param[in] aLandmarkDatabase The landmark database to manage categories in.
70 * @returns A new instance of this class.
72 IMPORT_C static CPosLmCategoryManager* NewL(
73 CPosLandmarkDatabase& aLandmarkDatabase
79 IMPORT_C virtual ~CPosLmCategoryManager();
84 * Reads a landmark category from the database.
86 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
88 * The client takes ownership of the returned category object.
90 * This function requires @p ReadUserData capability.
92 * @param aCategoryId The ID of the landmark category to read.
93 * @returns The requested landmark category. The category object is put
94 * on the cleanup stack.
96 * @leave KErrNotFound The landmark category does not exist in the database.
97 * @leave KErrPosLmNotInitialized Database is not yet initialized.
99 virtual CPosLandmarkCategory* ReadCategoryLC( TPosLmItemId aCategoryId ) = 0;
102 * Returns an object for iterating the landmark categories in the
105 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
107 * The iterator object is reset, so that the first
108 * @ref CPosLmItemIterator::NextL call will return the first landmark
111 * The client takes ownership of the returned iterator object.
113 * This function requires @p ReadUserData capability.
115 * @param[in] aSortPref How to sort the categories. Default is no sorting.
116 * @return The landmark iterator.
118 * @leave KErrPosLmNotInitialized Database is not yet initialized.
120 * @panic "Landmarks Client"-EPosInvalidEnumValue
121 * Client specified invalid sort preference.
123 virtual CPosLmItemIterator* CategoryIteratorL(
124 TCategorySortPref aSortPref = ECategorySortOrderNone
128 * Returns an object for iterating referenced landmark categories in
131 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
133 * A category is referenced if there are landmarks in the database which
134 * contains this category.
136 * The iterator object is reset, so that the first
137 * @ref CPosLmItemIterator::NextL call will return the first landmark
140 * The client takes ownership of the returned iterator object.
142 * This function requires @p ReadUserData capability.
144 * @param[in] aSortPref How to sort the categories. Default is no sorting.
145 * @return The landmark iterator.
147 * @leave KErrPosLmNotInitialized Database is not yet initialized.
149 * @panic "Landmarks Client"-EPosInvalidEnumValue
150 * Client specified invalid sort preference.
152 virtual CPosLmItemIterator* ReferencedCategoryIteratorL(
153 TCategorySortPref aSortPref = ECategorySortOrderNone
157 * Adds a landmark category to the database and returns its ID.
159 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
161 * Note: Clients are not allowed to create global categories.
163 * This function requires @p ReadUserData and @p WriteUserData
166 * @post Category is added to the database and category object
167 * has database item set (CPosLandmarkCategory::CategoryId()).
169 * @param[in,out] aCategory The landmark category to add.
170 * @return The ID of the new category.
172 * @leave KErrArgument 1) Input category does not have a name set or
173 * 2) if a global category is set in the category object.
174 * @leave KErrAlreadyExists A category with the same name
175 * already exists in the database.
176 * @leave KErrAccessDenied The database is read-only.
177 * @leave KErrPosLmNotInitialized Database is not yet initialized.
179 virtual TPosLmItemId AddCategoryL(
180 CPosLandmarkCategory& aCategory
184 * Updates a landmark category in the database.
186 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
188 * Note: Clients are not allowed to change the global category identifier in
189 * the category object.
191 * This function requires @p ReadUserData and @p WriteUserData
194 * @param[in] aCategory The new landmark category data.
196 * @leave KErrArgument 1) Input category does not have a name set or
197 * 2) if a global category identifier is changed in the category object.
198 * @leave KErrAlreadyExists A category with the same name
199 * already exists in the database.
200 * @leave KErrAccessDenied The database is read-only.
201 * @leave KErrPosLmNotInitialized Database is not yet initialized.
203 virtual void UpdateCategoryL(
204 const CPosLandmarkCategory& aCategory
208 * Removes a landmark category from the database.
210 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
212 * If the landmark category does not exist in the database, nothing
215 * This call will also remove the category from all landmarks which
218 * The function returns an operation object which can be run in either
219 * synchronous or asynchronous mode. If it is run in asynchronous mode
220 * the client can supervise the progress of the operation.
222 * If the @ref CPosLmOperation object is deleted before the operation
223 * is complete, it is possible that the category has not been removed,
224 * but some landmarks may no longer contain this category
226 * The client takes ownership of the returned operation object.
228 * While removing the category, this operation will acquire a
229 * write-lock on the database.
231 * This function requires @p ReadUserData and @p WriteUserData
234 * @param aCategoryId The ID of the landmark category to delete.
235 * @returns A handle to the operation.
237 * @leave KErrAccessDenied The database is read-only.
238 * @leave KErrPosLmNotInitialized Database is not yet initialized.
240 virtual CPosLmOperation* RemoveCategoryL( TPosLmItemId aCategoryId ) = 0;
243 * Remove a set of landmark categories from the database.
245 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
247 * If any of the landmark categories does not exist in the database, it
250 * This call will also remove the categories from all landmarks which
253 * The function returns an operation object which can be run in either
254 * synchronous or asynchronous mode. If it is run in asynchronous mode
255 * the client can supervise the progress of the operation.
257 * If the @ref CPosLmOperation object is deleted before the operation
258 * is complete, it is possible that only a subset of the landmark
259 * categories have been deleted.
261 * The client takes ownership of the returned operation object.
263 * If the database is read only, the returned operation will fail with error
264 * code @p KErrAccessDenied.
266 * This call will also remove the categories from all landmarks which
269 * While removing the category, this operation will acquire a
270 * write-lock on the database.
272 * This function requires @p ReadUserData and @p WriteUserData
275 * @param aCategoryIdArray The IDs of the landmark categories to delete.
276 * @returns A handle to the operation.
278 * @leave KErrPosLmNotInitialized Database is not yet initialized.
280 virtual CPosLmOperation* RemoveCategoriesL(
281 const RArray<TPosLmItemId>& aCategoryIdArray
285 * Adds a category to a set of landmarks.
287 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
289 * If any of the specified landmarks does not exist, the category will
290 * be added to the other landmarks. No error will be reported though.
292 * If the category is already contained in one of the landmarks, nothing
293 * will be further added to that landmark.
295 * The function returns an operation object which can be run in either
296 * synchronous or asynchronous mode. If it is run in asynchronous mode
297 * the client can supervise the progress of the operation.
299 * If the @ref CPosLmOperation object is deleted before the operation
300 * is complete, it is possible that the category has only been added
301 * to a subset of the landmarks.
303 * The client takes ownership of the returned operation object.
305 * Note: There is no need to call
306 * @p CPosLandmarkDatabase::UpdateLandmark for this change to take
309 * If the database is read only, the returned operation will fail with error
310 * code @p KErrAccessDenied.
312 * While adding the category to the landmarks, this operation will
313 * acquire a write-lock on the database.
315 * This function requires @p ReadUserData and @p WriteUserData
318 * @param[in] aCategoryId The category to add to the set of landmarks.
319 * @param[in] aLandmarkIdArray The landmarks to add the category to.
320 * @returns A handle to the operation.
322 * @leave KErrNotFound The specified category does not exist in database.
323 * @leave KErrPosLmNotInitialized Database is not yet initialized.
325 virtual CPosLmOperation* AddCategoryToLandmarksL(
326 TPosLmItemId aCategoryId,
327 RArray<TPosLmItemId>& aLandmarkIdArray
331 * Removes a category from a set of landmarks.
333 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
335 * If any of the specified landmarks does not exist, the category will
336 * be removed from the other landmarks. No error will be reported though.
338 * If the category is not found in one of the landmarks, nothing will
339 * happen for that landmark.
341 * The function returns an operation object which can be run in either
342 * synchronous or asynchronous mode. If it is run in asynchronous mode
343 * the client can supervise the progress of the operation.
345 * If the @ref CPosLmOperation object is deleted before the operation
346 * is complete, it is possible that the category has only been removed
347 * from a subset of the landmarks.
349 * The client takes ownership of the returned operation object.
351 * If the database is read only, the returned operation will fail with error
352 * code @p KErrAccessDenied.
354 * While removing the category from the landmarks, this operation will
355 * acquire a write-lock on the database.
357 * This function requires @p ReadUserData and @p WriteUserData
360 * @param[in] aCategoryId The category to remove from the set of landmarks.
361 * @param[in] aLandmarkIdArray The landmarks to remove the category from.
362 * @returns A handle to the operation.
364 * @leave KErrNotFound The specified category does not exist in database.
365 * @leave KErrPosLmNotInitialized Database is not yet initialized.
367 virtual CPosLmOperation* RemoveCategoryFromLandmarksL(
368 TPosLmItemId aCategoryId,
369 RArray<TPosLmItemId>& aLandmarkIdArray
373 * Gets a category by name.
375 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
377 * The category name must be unique in the database, so there cannot be
380 * This function only looks for an exact match.
382 * This function requires @p ReadUserData capability.
384 * @param[in] aCategoryName The name of the category to get.
385 * @return @p KPosLmNullItemId if the category was not found, otherwise
386 * the ID of the category item in the database.
388 * @leave KErrPosLmNotInitialized Database is not yet initialized.
390 virtual TPosLmItemId GetCategoryL(
391 const TDesC& aCategoryName
395 * Gets the ID of a global category.
397 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
399 * This function requires @p ReadUserData capability.
401 * @param[in] aGlobalCategory The global category to look for.
402 * @return @p KPosLmNullItemId if the category was not found, otherwise
403 * the ID of the category item in the database.
405 * @leave KErrPosLmNotInitialized Database is not yet initialized.
407 virtual TPosLmItemId GetGlobalCategoryL(
408 TPosLmGlobalCategory aGlobalCategory
412 * Gets the predefined name of a global category.
414 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
416 * @param[in] aGlobalCategory The global category to get a name for.
417 * @return The name of the global category or @p NULL if the category
420 * @leave KErrPosLmNotInitialized Database is not yet initialized.
422 virtual HBufC* GlobalCategoryNameL(
423 TPosLmGlobalCategory aGlobalCategory
427 * Resets the information for all global categories.
429 * @pre Database is initialized (see @ref CPosLandmarkDatabase::IsInitializingNeeded).
431 * Global categories usually has a default name and icon. The client
432 * can change the name and icon. This function resets the name and
433 * icon to the default ones.
435 * The function returns an operation object which can be run in either
436 * synchronous or asynchronous mode. If it is run in asynchronous mode
437 * the client can supervise the progress of the operation.
439 * If the @ref CPosLmOperation object is deleted before the operation
440 * is complete, it is possible that that only a subset of the global
441 * categories have been resetted.
443 * The client takes ownership of the returned operation object.
445 * While resetting, this operation will acquire a write-lock on the
448 * This function requires @p ReadUserData and @p WriteUserData
451 * @returns A handle to the operation.
453 * @leave KErrAccessDenied The database is read-only.
454 * @leave KErrPosLmNotInitialized Database is not yet initialized.
456 virtual CPosLmOperation* ResetGlobalCategoriesL() = 0;
461 IMPORT_C CPosLmCategoryManager();
465 // Prohibit copy constructor
466 CPosLmCategoryManager( const CPosLmCategoryManager& );
467 // Prohibit assigment operator
468 CPosLmCategoryManager& operator= ( const CPosLmCategoryManager& );
472 // Implementation UID
477 #endif // CPOSLMCATEGORYMANAGER_H