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