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: Mylocation engine header implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MYLOCATIONSENGINE_H__ |
|
20 #define __MYLOCATIONSENGINE_H__ |
|
21 |
|
22 // INCLUDES |
|
23 // calendar related headers |
|
24 #include <calsession.h> |
|
25 #include <calentryview.h> |
|
26 |
|
27 // Header for contact DB |
|
28 #include <cntdb.h> |
|
29 |
|
30 //Qt contacts mobility apis |
|
31 #include <qtcontacts.h> |
|
32 #include <qcontactmanager.h> |
|
33 |
|
34 // Header for landmarks db |
|
35 #include<EPos_CPosLandmarkDatabase.h> |
|
36 |
|
37 // mylocations database manager |
|
38 #include "maptileinterface.h" |
|
39 #include "mylocationsdatabasemanager.h" |
|
40 #include "lookupmaptiledb.h" |
|
41 #include "calendernotification.h" |
|
42 #include "mylocationgeotagtimerao.h" |
|
43 class GeocodeUpdate; |
|
44 class CContactSubscriber; |
|
45 class CCalendarSubscriber; |
|
46 using namespace QTM_NAMESPACE; |
|
47 |
|
48 /** |
|
49 * This class contains the required data for maptile image processing. |
|
50 * Each address added/modified in contact database will be added as queue |
|
51 * using this class for maptile processing. |
|
52 */ |
|
53 class CMapTileRequest: public CBase |
|
54 { |
|
55 public: |
|
56 //Consturctor |
|
57 CMapTileRequest():iLandmarkInfo(NULL),iAddressDetails(NULL){}; |
|
58 //Destrucotr |
|
59 ~CMapTileRequest(){delete iLandmarkInfo;delete iAddressDetails;}; |
|
60 public: |
|
61 //Landmark contains address details |
|
62 CPosLandmark* iLandmarkInfo; |
|
63 //single row address. |
|
64 HBufC* iAddressDetails; |
|
65 //entry id |
|
66 TInt32 iUId; |
|
67 //Address type |
|
68 TInt32 iAddressType; |
|
69 //Image path |
|
70 TFileName iImagePath; |
|
71 //Event type |
|
72 TInt iEventType; |
|
73 }; |
|
74 |
|
75 /** |
|
76 * This class stores the information required for maptile |
|
77 * processing when it is triggered from the application(contact) |
|
78 * viewer. |
|
79 */ |
|
80 class TAppAddressInfo |
|
81 { |
|
82 public: |
|
83 TInt iUid; |
|
84 TInt iAddressType; |
|
85 }; |
|
86 |
|
87 // CLASS DECLARATION |
|
88 /** Class used to listen on various database change events from applications like calendar, |
|
89 * contacts, landmarks |
|
90 * |
|
91 * This class listens on database change events from applications like contacts, calendar, landmarks |
|
92 * and triggers updating the Mylocations database accordingly. |
|
93 * This process starts on phone bootup and always runs in the background. |
|
94 */ |
|
95 class CMyLocationsEngine : public CActive, public MCalChangeCallBack2, |
|
96 public MContactDbObserver, public MMapTileObserver,public MNotifyChange, |
|
97 public MyLocationTimerObserver |
|
98 |
|
99 { |
|
100 |
|
101 public: |
|
102 |
|
103 /** |
|
104 * Contact address types |
|
105 */ |
|
106 enum TContactAddressType |
|
107 { |
|
108 /** Address Type Pref */ |
|
109 EAddressPref, |
|
110 /** Address type Work */ |
|
111 EAddressWork, |
|
112 /** Address type Home */ |
|
113 EAddressHome, |
|
114 }; |
|
115 |
|
116 public: |
|
117 |
|
118 /** |
|
119 * CMyLocationsEngine::NewL() |
|
120 */ |
|
121 static CMyLocationsEngine* CMyLocationsEngine::NewL(); |
|
122 |
|
123 /** |
|
124 * ~CMyLocationsEngine. |
|
125 * Virtual Destructor. |
|
126 */ |
|
127 virtual ~CMyLocationsEngine(); |
|
128 |
|
129 /** Starts calender change notification method to get callbacks when entries are added/modified/deleted in calender |
|
130 * |
|
131 */ |
|
132 void StartCalenderChangeNotifierL(); |
|
133 |
|
134 /** Starts contacts change notification method to get callbacks when entries are added/modified/deleted in contacts |
|
135 * |
|
136 */ |
|
137 void StartContactsChangeNotifierL(); |
|
138 |
|
139 /** Starts landmarks change notification method to get callbacks when entries are added/modified/deleted in landmarks |
|
140 * |
|
141 */ |
|
142 void StartLandmarksChangeNotifier(); |
|
143 |
|
144 |
|
145 |
|
146 /** Maps the source type change type to Mylocations entry change type |
|
147 * @param[in] aSrcType Source type of the change |
|
148 * @param[in] aChangeType Type of change ( added/modified/deleted ). |
|
149 * @return The mylocations entry change type value. |
|
150 */ |
|
151 TEntryChangeType MapChangeType( TUidSourceType aSrcType, TUint32 aChangeType ); |
|
152 |
|
153 #ifdef MYLOCATIONENGINE_UNIT_TEST |
|
154 public: |
|
155 #else |
|
156 private: |
|
157 #endif |
|
158 |
|
159 /** |
|
160 * ConstructL. |
|
161 * 2nd phase constructor. |
|
162 */ |
|
163 void ConstructL(); |
|
164 |
|
165 /** |
|
166 * CMyLocationsEngine. |
|
167 * C++ default constructor. |
|
168 */ |
|
169 CMyLocationsEngine(); |
|
170 |
|
171 /** Creates a landmark object from contact item's location details and checks whether address available. |
|
172 * @param[in] aContactAddress A contact address whose location details needs to be used to create landmark object. |
|
173 * @returns A valid landmark object if location in the contact item is validated, NULL otherwise. |
|
174 */ |
|
175 CPosLandmark* GetContactAddressDetailsLC( QContactAddress& aContactAddress ); |
|
176 |
|
177 /** |
|
178 * A call back function for calendar change notification |
|
179 * @param aChangeItems List of changes since the last notification. |
|
180 */ |
|
181 virtual void CalChangeNotification( RArray<TCalChangeEntry>& aChangeItems ); |
|
182 |
|
183 /** Tests the contact database observer event type and handles it. The ID of a |
|
184 * contact affected by the change event, if relevant, can be retrieved via TContactDbObserverEvent::iContactId. |
|
185 * @param aEvent Provides information about the change event. |
|
186 */ |
|
187 virtual void HandleDatabaseEventL( TContactDbObserverEvent aEvent ); |
|
188 |
|
189 /** |
|
190 * Triggers the maptile processing for complete address |
|
191 * @param aEvent Provides information about the change event. |
|
192 */ |
|
193 void TriggerMaptileRequestL( TContactDbObserverEvent& aEvent ); |
|
194 |
|
195 /** |
|
196 * Process the maptile database event and updates the maptile database |
|
197 * @param aEventType Provides information about the type of request address. |
|
198 * @param aLookupItem Provides information about single address of contact. |
|
199 */ |
|
200 void UpdateMaptileDatabaseL(TInt aEventType , |
|
201 TLookupItem& aLookupItem ); |
|
202 |
|
203 /** |
|
204 * Handles active object's request completion event. |
|
205 */ |
|
206 void RunL(); |
|
207 |
|
208 /** |
|
209 * Implements cancellation of an outstanding request. |
|
210 */ |
|
211 void DoCancel(); |
|
212 |
|
213 |
|
214 /** |
|
215 * Requests for map tile image , structure serch. |
|
216 * @param aLandmark Provides information about the address. |
|
217 * @param aAddressType Provides information about address type . |
|
218 * @param aUId, uid of the event. |
|
219 */ |
|
220 void RequestMapTileImageL( CPosLandmark& aLandmark, const TUidSourceType aAddressType, |
|
221 const TInt32 aUId, const TInt aEventType ); |
|
222 |
|
223 /** |
|
224 * Requests for map tile image , one box serch. |
|
225 * @param aAddressDetails Provides information about the address. |
|
226 * @param aAddressType Provides information about address type . |
|
227 * @param aUId, uid of the event. |
|
228 */ |
|
229 void RequestMapTileImageL(const TDesC& aAddressDetails, |
|
230 const TUidSourceType aAddressType, const TInt32 aUId,const TInt aEventType); |
|
231 |
|
232 /** |
|
233 * Checks whether contact has a valid geocoordinates. |
|
234 * @param aContact Provides all the required information about the contact. |
|
235 * @param aAddressType Provides information about address type . |
|
236 * @param aLatitude, Latitude information. |
|
237 * @param aLongitude, Longitude information. |
|
238 * @return If geocoordinate available returns TRUE otherwise FALSE |
|
239 */ |
|
240 TBool IsGeoCoordinateAvailable( QContact& aContact, |
|
241 QString aAddressType, double& aLatitude , double& aLongitude ); |
|
242 |
|
243 /** |
|
244 * Add to maptile request queue. |
|
245 * @param mapTileRequest, request queue. |
|
246 * @return If successful, retrun KErrNone, or return some systemwide error. |
|
247 */ |
|
248 TInt RequestExecute( CMapTileRequest* aMapTileRequest); |
|
249 /** |
|
250 * SetFolderPath. |
|
251 * Sets the maptile storing path. |
|
252 */ |
|
253 void SetFolderPathL(); |
|
254 |
|
255 /** |
|
256 * Refreshes calendar entries in mylocation databases. This is typically called when there is an undefined |
|
257 * change in calendar db. |
|
258 */ |
|
259 void RefreshCalendarEntryListL(); |
|
260 |
|
261 /** |
|
262 * Returns True if a calendar entry is available for a given id. |
|
263 */ |
|
264 TBool IsCalendarEntryValidL( TUint32 aId ); |
|
265 |
|
266 /** |
|
267 * Calender entry added. |
|
268 */ |
|
269 void CalenderEntryAddedL(TCalChangeEntry aCalChangeEntry); |
|
270 |
|
271 /** |
|
272 * Calender entry modifyied. |
|
273 */ |
|
274 void CalenderEntryModifyL(TCalChangeEntry aCalChangeEntry); |
|
275 /** |
|
276 * Update the mylocations database. |
|
277 */ |
|
278 void UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, |
|
279 const TUint32 aSourceType, const TEntryChangeType aChangeType ); |
|
280 |
|
281 /** |
|
282 * Informs the geocode completion |
|
283 */ |
|
284 void UpdateGeoCodeToAppDataBase( TReal latitude,TReal longitude ); |
|
285 |
|
286 /** |
|
287 * Process the pending maptile requests |
|
288 */ |
|
289 void ProcessNextMaptileRequest(); |
|
290 |
|
291 /** |
|
292 * maptile database manipulation. |
|
293 */ |
|
294 void ManipulateMapTileDataBaseL(TLookupItem& aLookupItem); |
|
295 |
|
296 /** |
|
297 * Crop and create multiple maptile images for different applications requirements. |
|
298 */ |
|
299 void CreateMultipleMaptiles( const TDesC& aMaptilePath ); |
|
300 |
|
301 /** |
|
302 * Crop the maptile image and save the different files. |
|
303 */ |
|
304 void CropAndSaveImage( QString filePath, int width, |
|
305 int height, QString appType, QString orientationType ); |
|
306 |
|
307 /**Get the contact name for this perticular id. |
|
308 */ |
|
309 void GetContactName( TInt32 iUId , TDes& aName ); |
|
310 |
|
311 public: //From MMapTileObserver |
|
312 |
|
313 /** |
|
314 * Informs the maptile fetching completion |
|
315 */ |
|
316 void MapTilefetchingCompleted( TInt aErrCode,const TDesC& aMapTilePath ); |
|
317 |
|
318 /** |
|
319 * Informs the geo codes fetching completion |
|
320 */ |
|
321 void GeoCodefetchingCompleted( TInt aErrCode, const TReal& aLatitude, |
|
322 const TReal& aLongitude, const TDesC& aMapTilePath ); |
|
323 public://from MNotifychange |
|
324 void NotifyChangeL(TInt &aStatus); |
|
325 void GetChangeNotificationL(TInt &aId, TInt &addressType, TInt &addressCount ); |
|
326 void SubscribeFromCalendarL(TInt aId); |
|
327 |
|
328 public: //from MyLocationTimerObserver |
|
329 /** |
|
330 * Notifies the timer expiry when 3AM timer was started to notify. |
|
331 */ |
|
332 void MyLocationThreeAMTimerExpiredL(); |
|
333 |
|
334 |
|
335 #ifdef MYLOCATIONENGINE_UNIT_TEST |
|
336 public: |
|
337 #else |
|
338 private: |
|
339 #endif |
|
340 |
|
341 // Data member |
|
342 |
|
343 //handle to timer class |
|
344 //calendar session handle |
|
345 CCalSession *iCalSession; |
|
346 |
|
347 // calendar view |
|
348 CCalEntryView *iCalView; |
|
349 |
|
350 // Handle to the contacts database |
|
351 CContactDatabase* iContactsDb; |
|
352 |
|
353 // Receives events reporting changes to a contact database. |
|
354 CContactChangeNotifier *iContactChangeNotifier; |
|
355 |
|
356 // Handle to landmarks db |
|
357 CPosLandmarkDatabase* iLandmarkDb; |
|
358 |
|
359 // landmark change event type. |
|
360 TPosLmEvent iLmEvent; |
|
361 |
|
362 //Handle to maptile interface |
|
363 CMapTileInterface* iMapTileInterface; |
|
364 |
|
365 CMyLocationsDatabaseManager* iMyLocationsDatabaseManager; |
|
366 |
|
367 //maptiledb |
|
368 CLookupMapTileDatabase* iMaptileDatabase; |
|
369 |
|
370 //Current event type |
|
371 TInt iEventType; |
|
372 |
|
373 //Maptile image request queue |
|
374 RArray<CMapTileRequest*> iMapTileRequestQueue; |
|
375 |
|
376 // 3am Timer |
|
377 CLocationGeoTagTimerAO *iMyLocationThreeAMTimer; |
|
378 |
|
379 //Flag to check maptilegeocoder plugin availability |
|
380 TBool iMaptileGeocoderPluginAvailable; |
|
381 |
|
382 //Maptile image path |
|
383 TFileName imageFilePath; |
|
384 |
|
385 //Object to listen calender db create notification. |
|
386 CCalenderNotification *iCalenderNotification; |
|
387 |
|
388 //Contact manager instance for retrieving contact info. |
|
389 QContactManager* iContactManager; |
|
390 |
|
391 //Subscribe from contact |
|
392 CContactSubscriber *iContactSubscriber; |
|
393 |
|
394 //Subscribe from calendar |
|
395 CCalendarSubscriber *iCalendarSubscriber; |
|
396 |
|
397 //Geo-code class instance |
|
398 GeocodeUpdate *iGeocodeUpdate; |
|
399 |
|
400 //Last viewed contact id |
|
401 TInt iLastContactId; |
|
402 |
|
403 //Last viewed calendar id |
|
404 TInt iLastCalendarId; |
|
405 |
|
406 //Address information for viewver maptile processing. |
|
407 RArray<TAppAddressInfo*> iAddressInfo; |
|
408 |
|
409 }; |
|
410 |
|
411 #endif // __MYLOCATIONSENGINE_H__ |
|
412 // End of File |
|