locationdataharvester/mylocationsengine/inc/mylocationsengine.h
branchGCC_SURGE
changeset 32 9bd2e0ffe298
parent 31 8db05346071b
child 35 59575560d1e6
equal deleted inserted replaced
25:a4fe51dd4d22 32:9bd2e0ffe298
    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"
       
    39 #include "calendernotification.h"
    41 #include "calendernotification.h"
       
    42 #include "mylocationgeotagtimerao.h"
       
    43 class GeocodeUpdate;
       
    44 class CContactSubscriber;
       
    45 class CCalendarSubscriber;
       
    46 using namespace QTM_NAMESPACE;
    40 
    47 
    41 /**  
    48 /**  
    42  * This class contains the required data  for maptile image  processing.
    49  * This class contains the required data  for maptile image  processing.
    43  * Each  address added/modified in contact database will be added as queue
    50  * Each  address added/modified in contact database will be added as queue
    44  * using this class for maptile processing.
    51  * using this class for maptile processing.
    53 public:
    60 public:
    54     //Landmark contains address details
    61     //Landmark contains address details
    55     CPosLandmark* iLandmarkInfo;
    62     CPosLandmark* iLandmarkInfo;
    56     //single row address.
    63     //single row address.
    57     HBufC* iAddressDetails;
    64     HBufC* iAddressDetails;
    58     //Contact id
    65     //entry id
    59     TInt32 iUId;
    66     TInt32 iUId;
    60     //Address type 
    67     //Address type 
    61     TInt32 iAddressType;
    68     TInt32 iAddressType;
    62     //Image path 
    69     //Image path 
    63     TFileName iImagePath;
    70     TFileName iImagePath;
    64     //Event type    
    71     //Event type    
    65     TInt iEventType;
    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;
    66 };
    85 };
    67 
    86 
    68 // CLASS DECLARATION
    87 // CLASS DECLARATION
    69 /**  Class used to listen on various database change events from applications like calendar, 
    88 /**  Class used to listen on various database change events from applications like calendar, 
    70  * contacts, landmarks
    89  * contacts, landmarks
    72  * This class listens on database change events from applications like contacts, calendar, landmarks
    91  * This class listens on database change events from applications like contacts, calendar, landmarks
    73  * and triggers updating the Mylocations database accordingly. 
    92  * and triggers updating the Mylocations database accordingly. 
    74  * This process starts on phone bootup and always runs in the background.
    93  * This process starts on phone bootup and always runs in the background.
    75  */
    94  */
    76 class CMyLocationsEngine : public CActive, public MCalChangeCallBack2,
    95 class CMyLocationsEngine : public CActive, public MCalChangeCallBack2,
    77 				 public MContactDbObserver, public MMapTileObserver,public MNotifyChange
    96 				 public MContactDbObserver, public MMapTileObserver,public MNotifyChange,
       
    97 				 public MyLocationTimerObserver
    78 			
    98 			
    79 {
    99 {
    80     
   100     
    81 public:
   101 public:
    82     
   102     
   128     * @param[in] aChangeType Type of change ( added/modified/deleted ).
   148     * @param[in] aChangeType Type of change ( added/modified/deleted ).
   129     * @return The mylocations entry change type value.
   149     * @return The mylocations entry change type value.
   130      */      
   150      */      
   131     TEntryChangeType MapChangeType( TUidSourceType aSrcType, TUint32 aChangeType );    
   151     TEntryChangeType MapChangeType( TUidSourceType aSrcType, TUint32 aChangeType );    
   132  
   152  
   133 
   153 #ifdef MYLOCATIONENGINE_UNIT_TEST
       
   154 public:
       
   155 #else
   134 private:
   156 private:
       
   157 #endif
   135     
   158     
   136     /**
   159     /**
   137      * ConstructL.
   160      * ConstructL.
   138      * 2nd phase constructor.
   161      * 2nd phase constructor.
   139      */
   162      */
   144      * C++ default constructor. 
   167      * C++ default constructor. 
   145      */
   168      */
   146     CMyLocationsEngine();
   169     CMyLocationsEngine();
   147     
   170     
   148     /** Creates a landmark object from contact item's location details and checks whether address available.
   171     /** 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.
   172      * @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.
   173      * @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.
   174      */      
   152      */      
   175     CPosLandmark* GetContactAddressDetailsLC( QContactAddress& aContactAddress );
   153     CPosLandmark* GetContactAddressDetailsLC( const CContactItem *aContactItem, 
       
   154             TContactAddressType aAddressType );
       
   155             
   176             
   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     /**
   177     /**
   174      *  A call back function for calendar change notification
   178      *  A call back function for calendar change notification
   175 	 *	@param aChangeItems  List of changes since the last notification.	
   179 	 *	@param aChangeItems  List of changes since the last notification.	
   176 	 */      
   180 	 */      
   177     virtual void CalChangeNotification( RArray<TCalChangeEntry>& aChangeItems );
   181     virtual void CalChangeNotification( RArray<TCalChangeEntry>& aChangeItems );
   187      * @param aEvent  Provides information about the change event.   
   191      * @param aEvent  Provides information about the change event.   
   188      */      
   192      */      
   189 	void TriggerMaptileRequestL(  TContactDbObserverEvent& aEvent  );
   193 	void TriggerMaptileRequestL(  TContactDbObserverEvent& aEvent  );
   190 			
   194 			
   191     /** 
   195     /** 
   192      * Process the contact database event and updates the landmark database
       
   193      * @param aEvent  Provides information about the change event.   
       
   194      */      
       
   195 	void HandlelandmarkDatabaseL( TContactDbObserverEvent& aEvent );
       
   196     /** 
       
   197     * Process the maptile database event and updates the maptile database
   196     * Process the maptile database event and updates the maptile database
   198     * @param aEventType  Provides information about the type of request address.
   197     * @param aEventType  Provides information about the type of request address.
   199     * @param aLookupItem Provides information about single address of contact.  
   198     * @param aLookupItem Provides information about single address of contact.  
   200     */  
   199     */  
   201 	void HandleMaptileDatabaseL(TInt aEventType ,
   200 	void UpdateMaptileDatabaseL(TInt aEventType ,
   202 	                             TLookupItem& aLookupItem );
   201 	                             TLookupItem& aLookupItem );
   203 
   202 	
   204     /**
   203     /**
   205      *  Handles active object's request completion event. 
   204      *  Handles active object's request completion event. 
   206      */
   205      */
   207     void RunL();
   206     void RunL();
   208 
   207 
   209     /** 
   208     /** 
   210      * Implements cancellation of an outstanding request. 
   209      * Implements cancellation of an outstanding request. 
   211      */
   210      */
   212     void DoCancel();
   211     void DoCancel();
   213  
   212  
       
   213     
   214     /** 
   214     /** 
   215      * Requests for map tile image , structure serch.
   215      * Requests for map tile image , structure serch.
   216      * @param aLandmark  Provides information about the address.
   216      * @param aLandmark  Provides information about the address.
   217      * @param aAddressType Provides information about address type .  
   217      * @param aAddressType Provides information about address type .  
   218      * @param aUId, uid of the event.
   218      * @param aUId, uid of the event.
   219      */
   219      */
   220     void RequestMapTileImageL( CPosLandmark&  aLandmark, const TUidSourceType aAddressType,
   220     void RequestMapTileImageL( CPosLandmark&  aLandmark, const TUidSourceType aAddressType,
   221                                const TInt32 aUId  );
   221                                const TInt32 aUId, const TInt aEventType  );
   222     
   222     
   223     /** 
   223     /** 
   224      * Requests for map tile image , one box serch.
   224      * Requests for map tile image , one box serch.
   225      * @param aAddressDetails  Provides information about the address.
   225      * @param aAddressDetails  Provides information about the address.
   226      * @param aAddressType Provides information about address type .  
   226      * @param aAddressType Provides information about address type .  
   227      * @param aUId, uid of the event.
   227      * @param aUId, uid of the event.
   228      */
   228      */
   229     void RequestMapTileImageL(const TDesC& aAddressDetails,
   229     void RequestMapTileImageL(const TDesC& aAddressDetails,
   230             const TUidSourceType aAddressType, const TInt32 aUId);
   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 );
   231     
   242     
   232     /** 
   243     /** 
   233      * Add to maptile request queue.
   244      * Add to maptile request queue.
   234      * @param mapTileRequest, request queue.
   245      * @param mapTileRequest, request queue.
   235      * @return If successful, retrun KErrNone, or return some systemwide error.
   246      * @return If successful, retrun KErrNone, or return some systemwide error.
   244     * Calender entry added.
   255     * Calender entry added.
   245     */
   256     */
   246     void CalenderEntryAddedL(TCalChangeEntry aCalChangeEntry);    
   257     void CalenderEntryAddedL(TCalChangeEntry aCalChangeEntry);    
   247 
   258 
   248     /**
   259     /**
       
   260     * Calender entry modifyied.
       
   261     */
       
   262     void CalenderEntryModifyL(TCalChangeEntry aCalChangeEntry);
       
   263     /**
   249     * Update the mylocations database.
   264     * Update the mylocations database.
   250     */
   265     */
   251     void UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, 
   266     void UpdateDatabaseL( CPosLandmark* aLandmark, const TUint32 aUid, 
   252             const TUint32 aSourceType, const TEntryChangeType aChangeType );
   267             const TUint32 aSourceType, const TEntryChangeType aChangeType );
   253 
   268 			
   254 
   269     /** 
       
   270      * Informs the geocode completion
       
   271      */
       
   272     void UpdateGeoCodeToAppDataBase( TReal latitude,TReal longitude );		
       
   273     
       
   274     /** 
       
   275      * Process the pending maptile requests
       
   276      */
       
   277     void ProcessNextMaptileRequest();
       
   278     
       
   279     /**
       
   280      * maptile database manipulation.
       
   281      */
       
   282     void ManipulateMapTileDataBaseL(TLookupItem& aLookupItem);
       
   283     
       
   284     /**
       
   285      * Crop and create multiple maptile images for different applications requirements.
       
   286      */
       
   287     void CreateMultipleMaptiles( const TDesC& aMaptilePath );
       
   288     
       
   289     /**
       
   290      * Crop the maptile image and save the different files.
       
   291      */
       
   292     void CropAndSaveImage( QString filePath, int width, 
       
   293                                int height, QString appType, QString orientationType );
       
   294      
   255 public:  //From MMapTileObserver
   295 public:  //From MMapTileObserver
   256     
   296     
   257     /**
   297     /**
   258      *  Informs the maptile fetching completion  
   298      *  Informs the maptile fetching completion  
   259      */ 
   299      */ 
   260     void MapTilefetchingCompleted( TInt aErrCode,const TDesC& aMapTilePath );
   300     void MapTilefetchingCompleted( TInt aErrCode,const TDesC& aMapTilePath );
   261     
   301     
   262     /** 
   302     /**
   263      * Informs the geocode completion
   303      *  Informs the geo codes fetching completion  
   264      */
   304      */
   265     void RestGeoCodeCompleted( TReal latitude,TReal longitude);
   305     void GeoCodefetchingCompleted( TInt aErrCode, const TReal& aLatitude,
   266     
   306 	                                   const TReal& aLongitude, const TDesC& aMapTilePath );
   267 public://from MNotifychange
   307 public://from MNotifychange
   268     void NotifyChangeL(TInt &aStatus);
   308     void NotifyChangeL(TInt &aStatus);
   269     
   309     void GetChangeNotificationL(TInt &aId, TInt &addressType, TInt &addressCount );
       
   310     void SubscribeFromCalendarL(TInt aId);
       
   311 	
       
   312 public: //from MyLocationTimerObserver
       
   313     /** 
       
   314      * Notifies the timer expiry when 3AM timer was started to notify. 
       
   315      */
       
   316     void MyLocationThreeAMTimerExpiredL();
       
   317 
       
   318     
       
   319 #ifdef MYLOCATIONENGINE_UNIT_TEST
       
   320 public:
       
   321 #else
   270 private:
   322 private:
       
   323 #endif
   271 
   324 
   272     // Data member
   325     // Data member
   273     
   326     
   274     //handle to timer class
   327     //handle to timer class
   275     //calendar session handle
   328     //calendar session handle
   299     CLookupMapTileDatabase* iMaptileDatabase;
   352     CLookupMapTileDatabase* iMaptileDatabase;
   300 
   353 
   301     //Current event type
   354     //Current event type
   302     TInt iEventType;
   355     TInt iEventType;
   303     
   356     
   304     //Address comparison pointer
       
   305     CAddressComparision *iAddressCompare;
       
   306     
       
   307     //Maptile image request queue
   357     //Maptile image request queue
   308     RArray<CMapTileRequest*> iMapTileRequestQueue;
   358     RArray<CMapTileRequest*> iMapTileRequestQueue;
       
   359     
       
   360     // 3am Timer
       
   361     CLocationGeoTagTimerAO *iMyLocationThreeAMTimer;
   309     
   362     
   310     //Flag to check maptilegeocoder plugin availability
   363     //Flag to check maptilegeocoder plugin availability
   311     TBool iMaptileGeocoderPluginAvailable;
   364     TBool iMaptileGeocoderPluginAvailable;
   312 	
   365 	
   313 	//Maptile image path
   366 	//Maptile image path
   314     TFileName imageFilePath;
   367     TFileName imageFilePath;
       
   368     
   315     //Object to listen calender db create notification.    
   369     //Object to listen calender db create notification.    
   316     CCalenderNotification  *iCalenderNotification;
   370     CCalenderNotification  *iCalenderNotification;
   317     
   371     
       
   372     //Contact manager instance for retrieving contact info.
       
   373     QContactManager* iContactManager;
       
   374     
       
   375     //Subscribe from contact
       
   376     CContactSubscriber *iContactSubscriber;
       
   377     
       
   378     //Subscribe from calendar
       
   379     CCalendarSubscriber *iCalendarSubscriber;
       
   380     
       
   381     //Geo-code class instance
       
   382     GeocodeUpdate *iGeocodeUpdate;
       
   383        
       
   384     //Last viewed contact id
       
   385     TInt iLastContactId;
       
   386     
       
   387     //Last viewed calendar id
       
   388     TInt iLastCalendarId;
       
   389     
       
   390     //Address information for viewver maptile processing.
       
   391     RArray<TAppAddressInfo*> iAddressInfo;
       
   392    
   318 };
   393 };
   319 
   394 
   320 #endif // __MYLOCATIONSENGINE_H__
   395 #endif // __MYLOCATIONSENGINE_H__
   321 // End of File
   396 // End of File