|
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 #ifdef LOCATION_DATA_HARVESTER_UNIT_TEST |
|
95 public: |
|
96 #else |
|
97 private: |
|
98 #endif |
|
99 |
|
100 /** |
|
101 * AddMylocationsCategory. |
|
102 * Adds the category to landmarks database. |
|
103 * Used to add location picker specific categories. |
|
104 * @param[in] aCategoryName defines the category name to be added. |
|
105 * @returns The category id. |
|
106 */ |
|
107 TUint32 AddMylocationsCategoryL( const TDesC& aCategoryName ); |
|
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 * HandleLandmarkModificationL. |
|
160 * Handles a landmark modification |
|
161 * @param[in] aLandmark Landmark object modified. |
|
162 * @param[in] aUid Uid of the source entry corresponding to aLandmark.. |
|
163 */ |
|
164 void HandleLandmarkModificationL( CPosLandmark* aLandmark, const TUint32 aUid ); |
|
165 /** |
|
166 * CheckAndReadLandmarkL. |
|
167 * Checks whether a category is available in database pointed by category manager. |
|
168 * @param[in] CPosLandmarkDatabase handle to the database manager |
|
169 * @param[in] aLmId Id of the landmark |
|
170 * @returns landmark object if found else NULL |
|
171 */ |
|
172 CPosLandmark* CheckAndReadLandmarkL( |
|
173 CPosLandmarkDatabase* aDb, const TUint32 aLmId ); |
|
174 /** |
|
175 * FillLookupItemAddressDetails. |
|
176 * Fills address details into QLookupItem from CPosLandmark. |
|
177 * @param[in] aLandmark a landmark object |
|
178 * @param[out] aLookupItem, a lookup item in which the address details are filled |
|
179 */ |
|
180 void FillLookupItemAddressDetails( CPosLandmark* aLandmark, QLookupItem &aLookupItem ); |
|
181 |
|
182 /** |
|
183 * UnsetDuplicateNextCalEntry. |
|
184 * Finds a calendar lookup entry whose detination id is aLandmarkId |
|
185 * and unsets it duplcate flag. |
|
186 * @param[in] aLandmarkId a landmark id. |
|
187 */ |
|
188 void UnsetDuplicateNextCalEntry( quint32 aLandmarkId ); |
|
189 |
|
190 /** |
|
191 * IsDuplicateCalEntry. |
|
192 * Checks if there is a duplicate entry present whose destination id |
|
193 * is aLandmarkId |
|
194 * @param[in] aLandmarkId a landmark id. |
|
195 */ |
|
196 bool IsDuplicateEntry( quint32 aLandmarkId ); |
|
197 |
|
198 /** |
|
199 * CreateLandmarkItemLC. |
|
200 * Creates a landmark from a QLookupItem |
|
201 * @param[in] aLookupItem a lookup item. |
|
202 * @returns CPosLandmark a newly created landmark. |
|
203 */ |
|
204 CPosLandmark* CreateLandmarkItemLC( const QLookupItem &aLookupItem ); |
|
205 |
|
206 #ifdef LOCATION_DATA_HARVESTER_UNIT_TEST |
|
207 public: |
|
208 #else |
|
209 private: |
|
210 #endif |
|
211 // Handle to the landmark database |
|
212 CPosLandmarkDatabase* iLandmarkDb; |
|
213 |
|
214 // Calendar category to be created for calendar related location entries in landmark database |
|
215 TPosLmItemId iLmCalendarCatId; |
|
216 // Contacts category to be created for contacts related location entries in landmark database |
|
217 TPosLmItemId iLmContactsCatId; |
|
218 |
|
219 // handle to the location app lookup database. |
|
220 LocationDataLookupDb* iLocationAppLookupDb; |
|
221 |
|
222 // handle to landmarks category manager |
|
223 CPosLmCategoryManager* iLandmarksCatManager; |
|
224 |
|
225 // handle to the file session |
|
226 RFs iFsSession; |
|
227 }; |
|
228 #endif // __MYLOCATIONSDATABASEMANAGER_H__ |