locationdataharvester/mylocationsengine/inc/mylocationsengine.h
changeset 26 f3533f6eae3f
parent 20 cd10d5b85554
child 30 96df3ab41000
equal deleted inserted replaced
24:ccec19943943 26:f3533f6eae3f
    18 
    18 
    19 #ifndef __MYLOCATIONSENGINE_H__
    19 #ifndef __MYLOCATIONSENGINE_H__
    20 #define __MYLOCATIONSENGINE_H__
    20 #define __MYLOCATIONSENGINE_H__
    21 
    21 
    22 // INCLUDES
    22 // INCLUDES
    23 
       
    24 // calendar related headers
    23 // calendar related headers
    25 #include <calsession.h>
    24 #include <calsession.h>
    26 #include <calentryview.h>
    25 #include <calentryview.h>
    27 
    26 
    28 // Header for contact DB
    27 // Header for contact DB
    29 #include <cntdb.h>
    28 #include <cntdb.h>
       
    29 
       
    30 //Qt contacts mobility apis
       
    31 #include <qtcontacts.h>
       
    32 #include <qcontactmanager.h>
    30 
    33 
    31 // Header for landmarks db
    34 // Header for landmarks db
    32 #include<EPos_CPosLandmarkDatabase.h>
    35 #include<EPos_CPosLandmarkDatabase.h>
    33 
    36 
    34 // mylocations database manager
    37 // mylocations database manager
    35 #include "maptileinterface.h"
    38 #include "maptileinterface.h"
    36 #include "mylocationsdatabasemanager.h"
    39 #include "mylocationsdatabasemanager.h"
    37 #include "lookupmaptiledb.h"
    40 #include "lookupmaptiledb.h"
    38 #include "addresscomparision.h"
    41 #include "addresscomparision.h"
    39 #include "calendernotification.h"
    42 #include "calendernotification.h"
       
    43 #include "mylocationgeotagtimerao.h"
       
    44 
       
    45 using namespace QTM_NAMESPACE;
    40 
    46 
    41 /**  
    47 /**  
    42  * This class contains the required data  for maptile image  processing.
    48  * This class contains the required data  for maptile image  processing.
    43  * Each  address added/modified in contact database will be added as queue
    49  * Each  address added/modified in contact database will be added as queue
    44  * using this class for maptile processing.
    50  * using this class for maptile processing.
    72  * This class listens on database change events from applications like contacts, calendar, landmarks
    78  * This class listens on database change events from applications like contacts, calendar, landmarks
    73  * and triggers updating the Mylocations database accordingly. 
    79  * and triggers updating the Mylocations database accordingly. 
    74  * This process starts on phone bootup and always runs in the background.
    80  * This process starts on phone bootup and always runs in the background.
    75  */
    81  */
    76 class CMyLocationsEngine : public CActive, public MCalChangeCallBack2,
    82 class CMyLocationsEngine : public CActive, public MCalChangeCallBack2,
    77 				 public MContactDbObserver, public MMapTileObserver,public MNotifyChange
    83 				 public MContactDbObserver, public MMapTileObserver,public MNotifyChange,
       
    84 				 public MyLocationTimerObserver
    78 			
    85 			
    79 {
    86 {
    80     
    87     
    81 public:
    88 public:
    82     
    89     
   128     * @param[in] aChangeType Type of change ( added/modified/deleted ).
   135     * @param[in] aChangeType Type of change ( added/modified/deleted ).
   129     * @return The mylocations entry change type value.
   136     * @return The mylocations entry change type value.
   130      */      
   137      */      
   131     TEntryChangeType MapChangeType( TUidSourceType aSrcType, TUint32 aChangeType );    
   138     TEntryChangeType MapChangeType( TUidSourceType aSrcType, TUint32 aChangeType );    
   132  
   139  
   133 
   140 #ifdef MYLOCATIONENGINE_UNIT_TEST
       
   141 public:
       
   142 #else
   134 private:
   143 private:
       
   144 #endif
   135     
   145     
   136     /**
   146     /**
   137      * ConstructL.
   147      * ConstructL.
   138      * 2nd phase constructor.
   148      * 2nd phase constructor.
   139      */
   149      */
   144      * C++ default constructor. 
   154      * C++ default constructor. 
   145      */
   155      */
   146     CMyLocationsEngine();
   156     CMyLocationsEngine();
   147     
   157     
   148     /** Creates a landmark object from contact item's location details and checks whether address available.
   158     /** Creates a landmark object from contact item's location details and checks whether address available.
   149     * @param[in] aContactItem A contact item whose location details needs to be used to create landmark object.
   159      * @param[in] aContactAddress A contact address whose location details needs to be used to create landmark object.
   150     * @param[in] aAddressType Mentions the address type ( prefered/work/home ) of the contact item to be used.
   160      * @returns A valid landmark object if location in the contact item is validated, NULL otherwise.
   151     * @returns A valid landmark object if location in the contact item is validated, NULL otherwise.
   161      */      
   152      */      
   162     CPosLandmark* GetContactAddressDetailsLC( QContactAddress& aContactAddress );
   153     CPosLandmark* GetContactAddressDetailsLC( const CContactItem *aContactItem, 
       
   154             TContactAddressType aAddressType );
       
   155             
   163             
   156     /** Creates a landmark object from contact item's location details
       
   157     * @param[in] aContactItem A contact item whose location details needs to be used to create landmark object.
       
   158     * @param[in] aAddressType Mentions the address type ( prefered/work/home ) of the contact item to be used.
       
   159     * @returns A valid landmark object if location in the contact item is validated, NULL otherwise.
       
   160     */    
       
   161     CPosLandmark* GetContactLocationDetailsLC( const CContactItem *aContactItem, 
       
   162            TContactAddressType aAddressType );
       
   163 
       
   164     /** Finds the contact's field type id
       
   165     * @param[in] aContactItem A contact item whose field details needs to found.
       
   166     * @param[in] aAddressType Mentions the address type ( prefered/work/home ) of the contact item to be used.
       
   167     * @param[in] aField The field type of interest.
       
   168     * @return If found, the index of the field within the field set, or KErrNotFound if not found.
       
   169     */      
       
   170     TInt FindContactsField( const CContactItem *aContactItem, TContactAddressType aAddressType, 
       
   171             TUid aField );
       
   172 
       
   173     /**
   164     /**
   174      *  A call back function for calendar change notification
   165      *  A call back function for calendar change notification
   175 	 *	@param aChangeItems  List of changes since the last notification.	
   166 	 *	@param aChangeItems  List of changes since the last notification.	
   176 	 */      
   167 	 */      
   177     virtual void CalChangeNotification( RArray<TCalChangeEntry>& aChangeItems );
   168     virtual void CalChangeNotification( RArray<TCalChangeEntry>& aChangeItems );
   196     /** 
   187     /** 
   197     * Process the maptile database event and updates the maptile database
   188     * Process the maptile database event and updates the maptile database
   198     * @param aEventType  Provides information about the type of request address.
   189     * @param aEventType  Provides information about the type of request address.
   199     * @param aLookupItem Provides information about single address of contact.  
   190     * @param aLookupItem Provides information about single address of contact.  
   200     */  
   191     */  
   201 	void HandleMaptileDatabaseL(TInt aEventType ,
   192 	void UpdateMaptileDatabaseL(TInt aEventType ,
   202 	                             TLookupItem& aLookupItem );
   193 	                             TLookupItem& aLookupItem );
   203 
   194 	
   204     /**
   195     /**
   205      *  Handles active object's request completion event. 
   196      *  Handles active object's request completion event. 
   206      */
   197      */
   207     void RunL();
   198     void RunL();
   208 
   199 
   209     /** 
   200     /** 
   210      * Implements cancellation of an outstanding request. 
   201      * Implements cancellation of an outstanding request. 
   211      */
   202      */
   212     void DoCancel();
   203     void DoCancel();
   213  
   204  
       
   205     
   214     /** 
   206     /** 
   215      * Requests for map tile image , structure serch.
   207      * Requests for map tile image , structure serch.
   216      * @param aLandmark  Provides information about the address.
   208      * @param aLandmark  Provides information about the address.
   217      * @param aAddressType Provides information about address type .  
   209      * @param aAddressType Provides information about address type .  
   218      * @param aUId, uid of the event.
   210      * @param aUId, uid of the event.
   226      * @param aAddressType Provides information about address type .  
   218      * @param aAddressType Provides information about address type .  
   227      * @param aUId, uid of the event.
   219      * @param aUId, uid of the event.
   228      */
   220      */
   229     void RequestMapTileImageL(const TDesC& aAddressDetails,
   221     void RequestMapTileImageL(const TDesC& aAddressDetails,
   230             const TUidSourceType aAddressType, const TInt32 aUId);
   222             const TUidSourceType aAddressType, const TInt32 aUId);
       
   223  
       
   224     /** 
       
   225      * Checks whether contact has a valid geocoordinates.
       
   226      * @param aContact  Provides all the required information about the contact.
       
   227      * @param aAddressType Provides information about address type .  
       
   228      * @param aLatitude, Latitude information.
       
   229      * @param aLongitude, Longitude information.
       
   230      * @return If geocoordinate available returns TRUE otherwise FALSE
       
   231      */    
       
   232     TBool IsGeoCoordinateAvailable( QContact& aContact, 
       
   233             QString aAddressType, double& aLatitude , double& aLongitude );
   231     
   234     
   232     /** 
   235     /** 
   233      * Add to maptile request queue.
   236      * Add to maptile request queue.
   234      * @param mapTileRequest, request queue.
   237      * @param mapTileRequest, request queue.
   235      * @return If successful, retrun KErrNone, or return some systemwide error.
   238      * @return If successful, retrun KErrNone, or return some systemwide error.
   248     /**
   251     /**
   249     * Update the mylocations database.
   252     * Update the mylocations database.
   250     */
   253     */
   251     void UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, 
   254     void UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, 
   252             const TUint32 aSourceType, const TEntryChangeType aChangeType );
   255             const TUint32 aSourceType, const TEntryChangeType aChangeType );
   253 
   256 			
   254 
   257     /** 
       
   258      * Informs the geocode completion
       
   259      */
       
   260     void UpdateGeoCodeToAppDataBase( TReal latitude,TReal longitude );		
       
   261     
       
   262     /** 
       
   263      * Process the pending maptile requests
       
   264      */
       
   265     void ProcessNextMaptileRequest();
       
   266     
       
   267     /**
       
   268      * maptile database manipulation.
       
   269      */
       
   270     void ManipulateMapTileDataBaseL(TLookupItem aLookupItem);
   255 public:  //From MMapTileObserver
   271 public:  //From MMapTileObserver
   256     
   272     
   257     /**
   273     /**
   258      *  Informs the maptile fetching completion  
   274      *  Informs the maptile fetching completion  
   259      */ 
   275      */ 
   260     void MapTilefetchingCompleted( TInt aErrCode,const TDesC& aMapTilePath );
   276     void MapTilefetchingCompleted( TInt aErrCode,const TDesC& aMapTilePath );
   261     
   277     
   262     /** 
   278     /**
   263      * Informs the geocode completion
   279      *  Informs the geo codes fetching completion  
   264      */
   280      */
   265     void RestGeoCodeCompleted( TReal latitude,TReal longitude);
   281     void GeoCodefetchingCompleted( TInt aErrCode, const TReal& aLatitude,
       
   282 	                                   const TReal& aLongitude, const TDesC& aMapTilePath );
       
   283     
       
   284 
   266     
   285     
   267 public://from MNotifychange
   286 public://from MNotifychange
   268     void NotifyChangeL(TInt &aStatus);
   287     void NotifyChangeL(TInt &aStatus);
       
   288 	
       
   289 public: //from MyLocationTimerObserver
       
   290     /** 
       
   291      * Notifies the timer expiry when 3AM timer was started to notify. 
       
   292      */
       
   293     void MyLocationThreeAMTimerExpiredL();
       
   294 
   269     
   295     
   270 private:
   296 private:
   271 
   297 
   272     // Data member
   298     // Data member
   273     
   299     
   305     CAddressComparision *iAddressCompare;
   331     CAddressComparision *iAddressCompare;
   306     
   332     
   307     //Maptile image request queue
   333     //Maptile image request queue
   308     RArray<CMapTileRequest*> iMapTileRequestQueue;
   334     RArray<CMapTileRequest*> iMapTileRequestQueue;
   309     
   335     
       
   336     // 3am Timer
       
   337     CLocationGeoTagTimerAO *iMyLocationThreeAMTimer;
       
   338     
   310     //Flag to check maptilegeocoder plugin availability
   339     //Flag to check maptilegeocoder plugin availability
   311     TBool iMaptileGeocoderPluginAvailable;
   340     TBool iMaptileGeocoderPluginAvailable;
   312 	
   341 	
   313 	//Maptile image path
   342 	//Maptile image path
   314     TFileName imageFilePath;
   343     TFileName imageFilePath;
       
   344     
   315     //Object to listen calender db create notification.    
   345     //Object to listen calender db create notification.    
   316     CCalenderNotification  *iCalenderNotification;
   346     CCalenderNotification  *iCalenderNotification;
   317     
   347     
       
   348     //Contact manager instance for retrieving contact info.
       
   349     QContactManager* iContactManager;
       
   350     
   318 };
   351 };
   319 
   352 
   320 #endif // __MYLOCATIONSENGINE_H__
   353 #endif // __MYLOCATIONSENGINE_H__
   321 // End of File
   354 // End of File