1 /* |
|
2 * Copyright (c) 2002-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 "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: LandmarksUi Content File - This class provides utility methods for performing |
|
15 * landmark database related operations like adding, deleting |
|
16 * or updating a landmark and category etc. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 #ifndef CLMKDBUTILS_H |
|
27 #define CLMKDBUTILS_H |
|
28 |
|
29 // INCLUDES |
|
30 #include <lbsfields.h> |
|
31 #include <EPos_Landmarks.h> |
|
32 #include "landmarks.hrh" |
|
33 #include "MLmkAOOperationObserver.h" |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CPosLandmarkCategory; |
|
37 class CPosLandmarkDatabase; |
|
38 class CPosLmCategoryManager; |
|
39 class CPosLmOperation; |
|
40 class CPosLandmark; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 /** |
|
44 * This class provides utility methods for performing operations related to |
|
45 * landmark database. |
|
46 * |
|
47 * Typical operations can be adding, deleting or updating landmark |
|
48 * and creating a new category or renaming a category etc. |
|
49 * |
|
50 * All the methods of this class except InitializeDbL() assume that the database |
|
51 * is opened and initialized. |
|
52 */ |
|
53 |
|
54 class CLmkDbUtils : public CBase, public MLmkAOOperationObserver |
|
55 { |
|
56 public: // Constructors and destructor |
|
57 /** |
|
58 * Create CLmkDbUtils object |
|
59 * @param aDb -- landmark database which needs to be accessed via this class |
|
60 * @param aObserver -- calling class or object as observer for this class |
|
61 * @aProgressNote - Note showing the progress of landmark database related |
|
62 * operations |
|
63 * @return newly instantiated object |
|
64 */ |
|
65 IMPORT_C static CLmkDbUtils* NewL( CPosLandmarkDatabase& aDb, |
|
66 MLmkAOOperationObserver& aObserver, |
|
67 TBool aProgressNote ); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 ~CLmkDbUtils(); |
|
73 |
|
74 private: // Constructors and destructor |
|
75 /** |
|
76 * C++ default constructor. |
|
77 * @param aDb -- landmark database |
|
78 * @param aObserver -- calling class passing itself as observer of this class |
|
79 * @param aProgressNote -- Note showing the progress of landmark database operations |
|
80 * @return newly instantiated object |
|
81 */ |
|
82 CLmkDbUtils( CPosLandmarkDatabase& aDb, |
|
83 MLmkAOOperationObserver& aObserver, |
|
84 TBool aProgressNote ); |
|
85 |
|
86 /** |
|
87 * By default Symbian 2nd phase constructor is private. |
|
88 */ |
|
89 void ConstructL(); |
|
90 |
|
91 protected: //from MLmkAOOperationObserver |
|
92 void HandleOperationL( TOperationTypes aType, |
|
93 TReal32 aProgress, |
|
94 TInt aStatus ); |
|
95 |
|
96 public: // New functions |
|
97 |
|
98 /** |
|
99 * Initializes landmark database. |
|
100 * This operation is asynchronous |
|
101 */ |
|
102 IMPORT_C void InitializeDbL(); |
|
103 |
|
104 /** |
|
105 * Compacts landmark database |
|
106 * This operation is asynchronous |
|
107 */ |
|
108 IMPORT_C void CompactDbL(); |
|
109 |
|
110 /** |
|
111 * Adds a new category to landmark database |
|
112 * This call is a synchronous one |
|
113 * |
|
114 * @param aCategory -- category which needs to be added to database |
|
115 * @param aDb -- landmark database to which category needs to be added |
|
116 */ |
|
117 IMPORT_C static void AddCategoryL( CPosLandmarkCategory& aCategory, |
|
118 CPosLandmarkDatabase& aDb ); |
|
119 |
|
120 /** |
|
121 * Rename category |
|
122 * This call is synchronous |
|
123 * @param aCategoryName -- name of the category which needs to be renamed |
|
124 * @param aId -- Unique identfier of the category in the database |
|
125 * @param aDb -- handle to landmark database |
|
126 */ |
|
127 IMPORT_C static void RenameCategoryL( TDesC& aCategoryName, |
|
128 TPosLmItemId aId, |
|
129 CPosLandmarkDatabase& aDb ); |
|
130 |
|
131 /** |
|
132 * Get category name given category and this call is synchronous |
|
133 * @param aDb Handle to landmark database |
|
134 * @param aCategoryId Identifier of the category in database whose |
|
135 * @return aCategoryName |
|
136 */ |
|
137 IMPORT_C static HBufC* CategoryNameL( |
|
138 CPosLandmarkDatabase& aDb, |
|
139 TPosLmItemId aCategoryId ); |
|
140 |
|
141 /** |
|
142 * Change the icon of category or landmark |
|
143 * This call is synchronous |
|
144 * @param aDb handle to landmark database |
|
145 * @param aId Identifier of the landmark or category whose icon needs to be changed |
|
146 * @param aItemType type of database item (landmark or category) |
|
147 * @param aMbmFileName Icon file name |
|
148 * @param aIconIndex Index of the icon in the icon file |
|
149 * @param aMaskIndex Index of icon mask in the icon file |
|
150 */ |
|
151 IMPORT_C static void ChangeIconL( CPosLandmarkDatabase& aDb, |
|
152 const TPosLmItemId aId, |
|
153 TLmkItemType aItemType, |
|
154 const TDesC& aMbmFileName, |
|
155 TInt aIconIndex, TInt aMaskIndex); |
|
156 |
|
157 /** |
|
158 * Change multiple item's icon |
|
159 * This is a asynchronous call |
|
160 * @param aIdArray Array of landmark database items whose icon needs to be changed |
|
161 * @param aItemsType Landmark or category |
|
162 * @param aMbmFileName name of icon file |
|
163 * @param aIconIndex Index of the icon inside the icon file |
|
164 * @param aMaskIndex Index of icon mask inside the icon file |
|
165 */ |
|
166 IMPORT_C void ChangeIconsL( |
|
167 const RArray<TPosLmItemId>& aIdArray, |
|
168 TLmkItemType aItemsType, |
|
169 const TDesC& aMbmFileName, |
|
170 TInt aIconIndex, TInt aMaskIndex); |
|
171 |
|
172 /** |
|
173 * Delete categories from landmark database |
|
174 * This is asynchronous method |
|
175 * @param aCategoryIdArray Array containing categories to be deleted |
|
176 */ |
|
177 IMPORT_C void DeleteCategoriesL( |
|
178 const RArray<TPosLmItemId>& aCategoryIdArray ); |
|
179 |
|
180 /** |
|
181 * Delete a single landmark from database |
|
182 * This is a synchronous method |
|
183 * @param aId Identifier of landmark to be deleted |
|
184 * @param aDb Handle to landmark database |
|
185 */ |
|
186 IMPORT_C static void DeleteLandmarkL( TPosLmItemId aId, |
|
187 CPosLandmarkDatabase& aDb ); |
|
188 |
|
189 /** |
|
190 * Delete a set of selected landmarks from landmark database |
|
191 * This is an Asynchronous method |
|
192 * @param aLandmarkIdArray Array containing the landmarks to be deleted |
|
193 */ |
|
194 IMPORT_C void DeleteLandmarksL( |
|
195 const RArray<TPosLmItemId>& aLandmarkIdArray ); |
|
196 |
|
197 /** |
|
198 * Adds a landmark to a category |
|
199 * This is synchronous |
|
200 * @param aLandmarkId Identifier of landmark |
|
201 * @param aCategoryId Identifier of category |
|
202 * @param aDb |
|
203 */ |
|
204 IMPORT_C static void AddLmToCategoryL( TPosLmItemId aLandmarkId, |
|
205 TPosLmItemId aCategoryId, |
|
206 CPosLandmarkDatabase& aDb ); |
|
207 |
|
208 /** |
|
209 * Adds a single landmark to a set of selected categories |
|
210 * This is asynchronous call |
|
211 * @param aLandmarkId Unique identifier of landmark which need to be added to set of categories |
|
212 * @param aCategoryIdArray Array containing categories |
|
213 */ |
|
214 IMPORT_C void AddLmToCategoriesL( |
|
215 TPosLmItemId aLandmarkId, |
|
216 const RArray<TPosLmItemId>& aCategoryIdArray ); |
|
217 |
|
218 /** |
|
219 * Adds multiple landmarks to one or more categories |
|
220 * This is an asynchronous call |
|
221 * @param aLandmarkIdArray Array of landmarks which need to be added to given categries |
|
222 * @param aCategoryIdArray Array of categories |
|
223 */ |
|
224 IMPORT_C void AddLmsToCategoriesL( |
|
225 const RArray<TPosLmItemId>& aLandmarkIdArray, |
|
226 const RArray<TPosLmItemId>& aCategoryIdArray ); |
|
227 |
|
228 /** |
|
229 * Cancel landmark database related operation |
|
230 * This cancels the Active Object created for landmark database related operation |
|
231 */ |
|
232 IMPORT_C void CancelLmOperation(); |
|
233 |
|
234 /** |
|
235 * It returns the category id,if given name |
|
236 */ |
|
237 IMPORT_C TPosLmItemId CategoryIdL(CPosLandmarkDatabase& aDb, const TDesC& aCategoryName ); |
|
238 |
|
239 /** |
|
240 * Checks if this field exists in the landmark. |
|
241 */ |
|
242 IMPORT_C TBool IsLmWithThisFieldExistL( TPositionFieldId aFieldId); |
|
243 |
|
244 /** |
|
245 * Checks, if the url value is >150 , it trims the protocol |
|
246 * since it assumes,that the protocol is appended by the sender |
|
247 * @param landmark The landmark, from which the url field value |
|
248 * to be trimmed. |
|
249 */ |
|
250 IMPORT_C static void RemoveDefaultProtocolL(TPtr& aWebUrl); |
|
251 /* |
|
252 * This function, appends the default protocol, if it is missing |
|
253 * from the url. |
|
254 */ |
|
255 IMPORT_C static void AddDefaultProtocolL(CPosLandmark* landmark); |
|
256 |
|
257 private: // New functions |
|
258 /** |
|
259 * This call checks if an Active Object is already running or not |
|
260 * Leaves if an Active Object is already running |
|
261 */ |
|
262 void LeaveIfInUseL(); |
|
263 |
|
264 /** |
|
265 * Helper method. It pushes the aOperation to the cleanup |
|
266 * stack as the first step, so caller does not have to do it. |
|
267 * @param aOperation, ownership is transferred |
|
268 * @param aOpType |
|
269 */ |
|
270 void SetupAndStartOperationL( |
|
271 CPosLmOperation* aOperation, |
|
272 MLmkAOOperationObserver::TOperationTypes aOpType ); |
|
273 |
|
274 |
|
275 private: // Data |
|
276 ///Ref: |
|
277 CPosLandmarkDatabase& iDb; |
|
278 |
|
279 ///Ref: |
|
280 MLmkAOOperationObserver* iObserver; |
|
281 |
|
282 TBool iProgressNote; |
|
283 |
|
284 ///Own: |
|
285 CLmkAOOperation* iAOOperation; |
|
286 |
|
287 ///Own: |
|
288 CPosLmCategoryManager* iCategoryMgr; |
|
289 }; |
|
290 |
|
291 #endif // CLMKDBUTILS_H |
|
292 |
|
293 // End of File |
|