|
1 /* |
|
2 * Copyright (c) 2010 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: Database manager implementation for location picker and |
|
15 * maptile service. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef __MYLOCATIONSDATABASEMANAGER_H__ |
|
20 #define __MYLOCATIONSDATABASEMANAGER_H__ |
|
21 |
|
22 // Landmarks |
|
23 #include<epos_cposlandmarkdatabase.h> |
|
24 #include <EPos_CPosLmCategoryManager.h> |
|
25 |
|
26 // Lookup database |
|
27 #include "mylocationslookupdb.h" |
|
28 |
|
29 // Maximum string length of landmark address. |
|
30 const TUint32 KMaxAddressLength = 255; |
|
31 |
|
32 /** Defines entry change type |
|
33 */ |
|
34 enum TEntryChangeType |
|
35 { |
|
36 /** Entry added */ |
|
37 EEntryAdded, |
|
38 /** Entry modified */ |
|
39 EEntryModified, |
|
40 /** Entry deleted */ |
|
41 EEntryDeleted, |
|
42 /** Entry change unknown */ |
|
43 EEntryUnknown |
|
44 }; |
|
45 |
|
46 |
|
47 /** |
|
48 * CMyLocationsDatabaseManager class. |
|
49 * This class handles all the operations related to mylocations landmark database. |
|
50 * |
|
51 */ |
|
52 class CMyLocationsDatabaseManager : public CBase |
|
53 { |
|
54 public: |
|
55 // Constructors and destructor |
|
56 |
|
57 /** |
|
58 * ConstructL. |
|
59 * 2nd phase constructor. |
|
60 */ |
|
61 void ConstructL(); |
|
62 |
|
63 /** |
|
64 * CMyLocationsDatabaseManager. |
|
65 * C++ default constructor. |
|
66 */ |
|
67 CMyLocationsDatabaseManager(); |
|
68 |
|
69 /** |
|
70 * ~CMyLocationsDatabaseManager. |
|
71 * Virtual Destructor. |
|
72 */ |
|
73 virtual ~CMyLocationsDatabaseManager(); |
|
74 |
|
75 public: |
|
76 /** |
|
77 * UpdateDatabaseL. |
|
78 * Updates the location into the landmark database and lookup table. |
|
79 * Based on the entry source type and the entry change type the updation can be |
|
80 * addition/modification/deletion. |
|
81 * |
|
82 * @param[in] aLandmark Landmark object to be updated in the database. |
|
83 * @param[in] aUid Uid of the changed source entry. |
|
84 * @param[in] aSourceType Source type of the aUid. |
|
85 * @param[in] aChangeType Type of change to the entry ( added/modified/deleted ) |
|
86 */ |
|
87 void UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
88 const TUint32 aSourceType, const TEntryChangeType aChangeType ); |
|
89 |
|
90 /** Gets the full address from a given landmark object |
|
91 * |
|
92 * @param[out] aLandmarkAddress comma separated landmark's full address |
|
93 * @param[in] aLandmark landmark object whose address needs to be found. |
|
94 */ |
|
95 void GetLandmarkFullAddress( TBuf<KMaxAddressLength>& aLandmarkAddress, |
|
96 const CPosLandmark* aLandmark ); |
|
97 |
|
98 |
|
99 private: |
|
100 |
|
101 /** |
|
102 * AddMylocationsCategory. |
|
103 * Adds the category to mylocations and landmarks database. |
|
104 * Used to add history and others categories. |
|
105 * @param[in] aCategoryType defines the category type to be added. |
|
106 */ |
|
107 void AddMylocationsCategoryL( const TUint32 aCategoryType ); |
|
108 |
|
109 /** |
|
110 * CheckIfDuplicateExistsL. |
|
111 * Checks if this landmark is already present in database. |
|
112 * If present returns the landmark id, else 0. |
|
113 * @param[in] aLandmark A landmark object to be checked for. |
|
114 * @returns If no duplicate is found in database returns 0 |
|
115 * else returns the id of the found landmark. |
|
116 */ |
|
117 TPosLmItemId CheckIfDuplicateExistsL( const CPosLandmark* aLandmark ); |
|
118 |
|
119 /** |
|
120 * CompareLandmarks. |
|
121 * Compares two landmarks. Only the text fields, landmark name, |
|
122 * street, city, state country and postal code are compared. |
|
123 * @param[in] aLandmark1 First landmark object to be compared. |
|
124 * @param[in] aLandmark2 Second landmark object to be compared. |
|
125 * @returns ETrue if the landmarks are same, else returns EFalse. |
|
126 */ |
|
127 TBool CompareLandmarks( const CPosLandmark* alandmark1, |
|
128 const CPosLandmark* alandmark2 ); |
|
129 |
|
130 /** |
|
131 * HandleEntryAdditionL. |
|
132 * Handles the entry addition in lookup table and landmarks db |
|
133 * @param[in] aLandmark Landmark object added. |
|
134 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
135 * @param[in] aSourceType source type of the aUid passed. |
|
136 */ |
|
137 void HandleEntryAdditionL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
138 const TUint32 aSourceType ); |
|
139 |
|
140 /** |
|
141 * HandleEntryModificationL. |
|
142 * Handles the entry modification in lookup table and landmarks db |
|
143 * @param[in] aLandmark Landmark object modified. |
|
144 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
145 * @param[in] aSourceType source type of the aUid passed. |
|
146 */ |
|
147 void HandleEntryModificationL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
148 const TUint32 aSourceType ); |
|
149 |
|
150 /** |
|
151 * HandleEntryDeletionL. |
|
152 * Handles the entry deletion in lookup table and landmarks db |
|
153 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
154 * @param[in] aSourceType source type of the aUid passed. |
|
155 */ |
|
156 void HandleEntryDeletionL( const TUint32 aUid, const TUint32 aSourceType ); |
|
157 |
|
158 /** |
|
159 * AddToMylocationsDbL. |
|
160 * Adds entry into mylocations db and also updates the lookup table |
|
161 * @param[in] aLandmark Landmark object to be added. |
|
162 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
163 * @param[in] aSourceType source type of the aUid passed. |
|
164 */ |
|
165 void AddToMylocationsDbL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
166 const TUint32 aSourceType ); |
|
167 |
|
168 /** |
|
169 * ModifyMylocationsDbL. |
|
170 * Updates the entry into mylocations db and also updates the lookup table |
|
171 * @param[in] aLandmark Landmark object modified. |
|
172 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
173 * @param[in] aSourceType source type of the aUid passed. |
|
174 */ |
|
175 void ModifyMylocationsDbL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
176 const TUint32 aSourceType ); |
|
177 |
|
178 /** |
|
179 * DeleteFromMylocationsDbL. |
|
180 * Deletes the entry from mylocations db and also updates the lookup table |
|
181 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
182 * @param[in] aSourceType source type of the aUid passed. |
|
183 */ |
|
184 void DeleteFromMylocationsDbL( const TUint32 aUid, const TUint32 aSourceType ); |
|
185 |
|
186 /** |
|
187 * CreateCategoryL. |
|
188 * Creates a new category in Mylocations Db and adds a corresponding entry in |
|
189 * mylocations lookup table. |
|
190 * @param[in] aUid Uid of the source category. |
|
191 */ |
|
192 void CreateCategoryL( const TUint32 aUid ); |
|
193 |
|
194 /** |
|
195 * CheckCategoryAvailabilityL. |
|
196 * Checks whether a category is available in database pointed by category manager. |
|
197 * @param[in] aCategoryManager handle to the category manager |
|
198 * @param[in] aCategoryId Id of the category |
|
199 */ |
|
200 void CheckCategoryAvailabilityL( CPosLmCategoryManager* aCategoryManager, |
|
201 const TUint32 aCategoryId ); |
|
202 |
|
203 /** |
|
204 * CheckAndReadLandmarkL. |
|
205 * Checks whether a category is available in database pointed by category manager. |
|
206 * @param[in] CPosLandmarkDatabase handle to the database manager |
|
207 * @param[in] aLmId Id of the landmark |
|
208 * @returns landmark object if found else NULL |
|
209 */ |
|
210 CPosLandmark* CMyLocationsDatabaseManager::CheckAndReadLandmarkL( |
|
211 CPosLandmarkDatabase* aDb, const TUint32 aLmId ); |
|
212 |
|
213 private: |
|
214 |
|
215 // Handle to the landmark database |
|
216 CPosLandmarkDatabase* iLandmarkDb; |
|
217 |
|
218 // Handle to the mylocations landmark database |
|
219 CPosLandmarkDatabase* iMyLocationsLandmarksDb; |
|
220 |
|
221 // Contacts category to be created for contacts and calendar |
|
222 // related location entries in landmark database |
|
223 TPosLmItemId iLmContactsCatId; |
|
224 |
|
225 // handle to landmarks lookup database. |
|
226 CLookupDatabase* iLandmarksLookupDb; |
|
227 |
|
228 // handle to mylocations lookup database. |
|
229 CLookupDatabase* iMylocationsLookupDb; |
|
230 |
|
231 // handle to mylocations category manager |
|
232 CPosLmCategoryManager* iMyLocationsCatManager; |
|
233 |
|
234 // handle to landmarks category manager |
|
235 CPosLmCategoryManager* iLandmarksCatManager; |
|
236 |
|
237 // handle to the file session |
|
238 RFs iFsSession; |
|
239 |
|
240 }; |
|
241 |
|
242 #endif // __MYLOCATIONSDATABASEMANAGER_H__ |