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 |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __MYLOCATIONSDATABASEMANAGER_H__ |
|
19 #define __MYLOCATIONSDATABASEMANAGER_H__ |
|
20 |
|
21 |
|
22 #include <EPos_CPosLandmark.h> |
|
23 |
|
24 #include <locationservicedefines.h> |
|
25 // lookup database |
|
26 #include <locationdatalookupdb.h> |
|
27 |
|
28 |
|
29 class CPosLandmarkDatabase; |
|
30 class CPosLmCategoryManager; |
|
31 |
|
32 |
|
33 /** |
|
34 * CMyLocationsDatabaseManager class. |
|
35 * This class handles all the operations related to mylocations landmark database. |
|
36 * |
|
37 */ |
|
38 class CMyLocationsDatabaseManager : public CBase |
|
39 { |
|
40 public: |
|
41 |
|
42 // Constructors and destructor |
|
43 |
|
44 /** |
|
45 * CMyLocationsDatabaseManager. |
|
46 * C++ default constructor. |
|
47 */ |
|
48 IMPORT_C CMyLocationsDatabaseManager(); |
|
49 |
|
50 /** |
|
51 * ConstructL. |
|
52 * 2nd phase constructor. |
|
53 */ |
|
54 IMPORT_C void ConstructL(); |
|
55 |
|
56 /** |
|
57 * ~CMyLocationsDatabaseManager. |
|
58 * Virtual Destructor. |
|
59 */ |
|
60 virtual ~CMyLocationsDatabaseManager(); |
|
61 |
|
62 public: |
|
63 /** |
|
64 * UpdateDatabaseL. |
|
65 * Updates the location into the landmark database and lookup table. |
|
66 * Based on the entry source type and the entry change type the updation can be |
|
67 * addition/modification/deletion. |
|
68 * |
|
69 * @param[in] aLandmark Landmark object to be updated in the database. |
|
70 * @param[in] aUid Uid of the changed source entry. |
|
71 * @param[in] aSourceType Source type of the aUid. |
|
72 * @param[in] aChangeType Type of change to the entry ( added/modified/deleted ) |
|
73 */ |
|
74 IMPORT_C void UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
75 const TUint32 aSourceType, const TUint32 aChangeType ); |
|
76 |
|
77 /** Gets the full address from a given landmark object |
|
78 * |
|
79 * @param[out] aLandmarkAddress comma separated landmark's full address |
|
80 * @param[in] aLandmark landmark object whose address needs to be found. |
|
81 */ |
|
82 IMPORT_C void GetLandmarkFullAddress( TBuf<255>& aLandmarkAddress, |
|
83 const CPosLandmark* aLandmark ); |
|
84 |
|
85 /** Update the maptile path to mylocation lookup table |
|
86 * |
|
87 * @param[in] aSourceId Uid of the changed source entry. |
|
88 * @param[in] aSourceType Source type of the aSourceId. |
|
89 * @param[in] aFilePath Maptile file path. |
|
90 */ |
|
91 IMPORT_C void UpdateMapTilePath( TUint32 aSourceId, TUint32 aSourceType, |
|
92 TFileName& aFilePath ); |
|
93 |
|
94 /** Update the maptile path to mylocation lookup table |
|
95 * |
|
96 * @param[in] aSourceId Uid of the changed source entry. |
|
97 * @param[in] aSourceType Source type of the aSourceId. |
|
98 * @param[in] aName entry name. |
|
99 */ |
|
100 |
|
101 IMPORT_C void UpdateEntryName( TUint32 aSourceId, TUidSourceType aSourceType, |
|
102 const TDesC& aName ); |
|
103 |
|
104 /** Compare the address details to lplookupaddres table |
|
105 * |
|
106 * @param aLandmarks , address formed as landmark object |
|
107 * @parama Id , id of entry to be checked in db table |
|
108 * @param aAddressType , type of entry. |
|
109 * @return , true for match case . |
|
110 */ |
|
111 IMPORT_C TBool CheckIfAddressChanged(const CPosLandmark& aLandmarks, |
|
112 const TUint32 aId, const TUidSourceType aAddressType); |
|
113 |
|
114 /** Compare the address details to lplookupaddres table |
|
115 * |
|
116 * @param aAddress , one line address . |
|
117 * @parama Id , id of entry to be checked in db table |
|
118 * @param aAddressType , type of entry. |
|
119 * @return , true for match case . |
|
120 */ |
|
121 IMPORT_C TBool CheckIfAddressChanged(const TDesC& aAddress, |
|
122 const TUint32 aId, const TUidSourceType aAddressType); |
|
123 |
|
124 |
|
125 #ifdef LOCATION_DATA_HARVESTER_UNIT_TEST |
|
126 public: |
|
127 #else |
|
128 private: |
|
129 #endif |
|
130 |
|
131 /** |
|
132 * AddMylocationsCategory. |
|
133 * Adds the category to landmarks database. |
|
134 * Used to add location picker specific categories. |
|
135 * @param[in] aCategoryName defines the category name to be added. |
|
136 * @returns The category id. |
|
137 */ |
|
138 TUint32 AddMylocationsCategoryL( const TDesC& aCategoryName ); |
|
139 |
|
140 /** |
|
141 * CheckIfDuplicateExistsL. |
|
142 * Checks if this landmark is already present in database. |
|
143 * If present returns the landmark id, else 0. |
|
144 * @param[in] aLandmark A landmark object to be checked for. |
|
145 * @returns If no duplicate is found in database returns 0 |
|
146 * else returns the id of the found landmark. |
|
147 */ |
|
148 TPosLmItemId CheckIfDuplicateExistsL( const CPosLandmark* aLandmark ); |
|
149 |
|
150 /** |
|
151 * CompareLandmarks. |
|
152 * Compares two landmarks. Only the text fields, landmark name, |
|
153 * street, city, state country and postal code are compared. |
|
154 * @param[in] aLandmark1 First landmark object to be compared. |
|
155 * @param[in] aLandmark2 Second landmark object to be compared. |
|
156 * @returns ETrue if the landmarks are same, else returns EFalse. |
|
157 */ |
|
158 TBool CompareLandmarks( const CPosLandmark* alandmark1, |
|
159 const CPosLandmark* alandmark2 ); |
|
160 |
|
161 /** |
|
162 * HandleEntryAdditionL. |
|
163 * Handles the entry addition in lookup table and landmarks db |
|
164 * @param[in] aLandmark Landmark object added. |
|
165 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
166 * @param[in] aSourceType source type of the aUid passed. |
|
167 */ |
|
168 void HandleEntryAdditionL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
169 const TUint32 aSourceType ); |
|
170 |
|
171 /** |
|
172 * HandleEntryModificationL. |
|
173 * Handles the entry modification in lookup table and landmarks db |
|
174 * @param[in] aLandmark Landmark object modified. |
|
175 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
176 * @param[in] aSourceType source type of the aUid passed. |
|
177 */ |
|
178 void HandleEntryModificationL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
179 const TUint32 aSourceType ); |
|
180 |
|
181 /** |
|
182 * HandleEntryDeletionL. |
|
183 * Handles the entry deletion in lookup table and landmarks db |
|
184 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
185 * @param[in] aSourceType source type of the aUid passed. |
|
186 */ |
|
187 void HandleEntryDeletionL( const TUint32 aUid, const TUint32 aSourceType ); |
|
188 |
|
189 /** |
|
190 * HandleLandmarkModificationL. |
|
191 * Handles a landmark modification |
|
192 * @param[in] aLandmark Landmark object modified. |
|
193 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
194 */ |
|
195 void HandleLandmarkModificationL( CPosLandmark* aLandmark, const TUint32 aUid ); |
|
196 /** |
|
197 * CheckAndReadLandmarkL. |
|
198 * Checks whether a category is available in database pointed by category manager. |
|
199 * @param[in] CPosLandmarkDatabase handle to the database manager |
|
200 * @param[in] aLmId Id of the landmark |
|
201 * @returns landmark object if found else NULL |
|
202 */ |
|
203 CPosLandmark* CheckAndReadLandmarkL( |
|
204 CPosLandmarkDatabase* aDb, const TUint32 aLmId ); |
|
205 /** |
|
206 * FillLookupItemAddressDetails. |
|
207 * Fills address details into QLookupItem from CPosLandmark. |
|
208 * @param[in] aLandmark a landmark object |
|
209 * @param[out] aLookupItem, a lookup item in which the address details are filled |
|
210 */ |
|
211 void FillLookupItemAddressDetails( CPosLandmark* aLandmark, QLookupItem &aLookupItem ); |
|
212 |
|
213 /** |
|
214 * UnsetDuplicateNextCalEntry. |
|
215 * Finds next calendar lookup entry whose detination id is aLandmarkId |
|
216 * and unsets it duplcate flag. |
|
217 * @param[in] aCurrentCalUid current calendar entry id. |
|
218 * @param[in] aLandmarkId a landmark id. |
|
219 */ |
|
220 void UnsetDuplicateNextCalEntry( quint32 aCurrentCalUid, quint32 aLandmarkId ); |
|
221 |
|
222 /** |
|
223 * IsDuplicateCalEntry. |
|
224 * Checks if there is a duplicate entry present whose destination id |
|
225 * is aLandmarkId |
|
226 * @param[in] aLandmarkId a landmark id. |
|
227 */ |
|
228 bool IsDuplicateEntry( quint32 aLandmarkId ); |
|
229 |
|
230 /** |
|
231 * CreateLandmarkItemLC. |
|
232 * Creates a landmark from a QLookupItem |
|
233 * @param[in] aLookupItem a lookup item. |
|
234 * @returns CPosLandmark a newly created landmark. |
|
235 */ |
|
236 CPosLandmark* CreateLandmarkItemLC( const QLookupItem &aLookupItem ); |
|
237 |
|
238 #ifdef LOCATION_DATA_HARVESTER_UNIT_TEST |
|
239 public: |
|
240 #else |
|
241 private: |
|
242 #endif |
|
243 // Handle to the landmark database |
|
244 CPosLandmarkDatabase* iLandmarkDb; |
|
245 |
|
246 // Calendar category to be created for calendar related location entries in landmark database |
|
247 TPosLmItemId iLmCalendarCatId; |
|
248 // Contacts category to be created for contacts related location entries in landmark database |
|
249 TPosLmItemId iLmContactsCatId; |
|
250 |
|
251 // handle to the location app lookup database. |
|
252 LocationDataLookupDb* iLocationAppLookupDb; |
|
253 |
|
254 // handle to landmarks category manager |
|
255 CPosLmCategoryManager* iLandmarksCatManager; |
|
256 |
|
257 // handle to the file session |
|
258 RFs iFsSession; |
|
259 }; |
|
260 #endif // __MYLOCATIONSDATABASEMANAGER_H__ |
|