serviceproviders/sapi_location/tsrc/dev/tlocmanualtest/inc/locationservice.h
changeset 22 fc9cf246af83
parent 19 989d2f495d90
child 23 5c0037c72160
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
     1 /*
       
     2 * Copyright (c) 2006-2007 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 the License "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:   Header file for location SAPI service implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef LOCATIONSERVICE_H
       
    20 #define LOCATIONSERVICE_H
       
    21 
       
    22 #include <lbs.h>
       
    23 class CGetLoc;
       
    24 /**
       
    25  * Identity for location SAPI lib 
       
    26  * This will be appended to requestor identity information stack received from the 
       
    27  * client and will be passed onto location server
       
    28  */
       
    29 
       
    30 _LIT(KIdentity,"Location SAPI");
       
    31 
       
    32 /**
       
    33  * Key for locating active objects associated with async request in registration table
       
    34  *
       
    35  * @ 0 for  Getlocation async Active object
       
    36  * @ 1 for Trace async active object
       
    37  */
       
    38  
       
    39 const TInt KARRAY_INDEX_GETLOCATION = 0 ;
       
    40 const TInt KARRAY_INDEX_TRACE       = 1 ; 
       
    41 
       
    42 
       
    43 
       
    44 /**
       
    45  * Key for locating location information in CLiwGenericParamList
       
    46  */
       
    47 _LIT8(KLongitudeKey,"Longitude") ;
       
    48 _LIT8(KLatitudeKey , "Latitude") ;
       
    49 _LIT8(KAltitudeKey , "Altitude") ;
       
    50 
       
    51 _LIT(KUnknown,"Unknown");
       
    52 
       
    53 /**
       
    54  * Default Update options
       
    55  */
       
    56 //Second
       
    57 const TInt KSSecond = 1000000;
       
    58 
       
    59 //Update interval
       
    60 const TInt KSUpdateInterval = KSSecond;
       
    61 
       
    62 //Update time out
       
    63 const TInt KSUpdateTimeOut = 15*KSSecond;
       
    64 
       
    65 //MaxAge
       
    66 const TInt KSMaxAge = 0;
       
    67 
       
    68 /**
       
    69  * Enums required for mathoperations
       
    70  */
       
    71 enum TMathOperationChoice
       
    72 	{
       
    73 	EDistance  = 0,
       
    74 	EBearingTo = 1,
       
    75 	EMove      = 2
       
    76 	};
       
    77 
       
    78 /**
       
    79  * Notification Type to be cancelled
       
    80  */
       
    81 enum TCancelParam
       
    82     {
       
    83 	ECancelGetLocation = 0,
       
    84 	ECancelTrace = 1
       
    85     }; 
       
    86 /**
       
    87  * Enumeration used to identify category of location information user intends to 
       
    88  * retrieve
       
    89  * Example: specifying EBasic user will get only longitude,latitude and altitude
       
    90  */
       
    91  enum TLocationInfoType
       
    92 	 {
       
    93 	 EBasicInfo = 0,
       
    94 	 EGenericInfo = 1	
       
    95 	 };
       
    96 
       
    97 /**
       
    98  * used by the caller of math operation to send input parameters 
       
    99  * after computation MathOperation wil fill in result field of this
       
   100  * struct.
       
   101  */
       
   102 struct _INPPARM
       
   103 	{
       
   104     //specifies option for mathoperation
       
   105 	TInt servicechoice;
       
   106 	//result of the computation
       
   107 	TReal32 result ;
       
   108 	//Source Coordinate for math operation
       
   109 	TCoordinate source;
       
   110 	//Destination Coordinate for math operation
       
   111 	TCoordinate destination ;
       
   112 	//In case of find bearingto following two should be supplied by the consumer
       
   113 	TReal32 bearing;
       
   114 	TReal32 distance;
       
   115 	
       
   116 	};
       
   117 
       
   118 typedef struct _INPPARM inpparam;
       
   119 
       
   120 
       
   121 
       
   122 /**
       
   123  *  Location callback interface, its pure interface class, application need to 
       
   124  *  Write there own callback derriving from this class.
       
   125  *  @Depenedency lbs.lib
       
   126  */
       
   127  
       
   128  class MLocationCallBack 
       
   129     {
       
   130     /**
       
   131      * Handles notifications caused by an asynchronous GetLocationL,
       
   132      * or by trace.
       
   133      *
       
   134      * @param aOutPos updated position got from location server
       
   135      * @return Success/Error code for the callback.
       
   136      *
       
   137      * @see HPositionGenericInfo in LbsPositionInfo.h for details
       
   138      *
       
   139      */
       
   140     public :
       
   141     virtual TInt HandleNotifyL(HPositionGenericInfo* aOutPos , TInt aError) = 0 ;
       
   142     };
       
   143 
       
   144 
       
   145 /**
       
   146  * CLocationService class : This is a wrapper class for the Functionalities 
       
   147  * offered by Location Retreival APIs.
       
   148  * In case of An Asynchronus request it has method which Instantiates and delegate 
       
   149  * the job to another class which  also opens new sub-session with
       
   150  * Location server.
       
   151  */ 
       
   152 
       
   153 
       
   154 class CLocationService : public CBase 
       
   155     {
       
   156     public :
       
   157 	    /**
       
   158         * Creates a new instance of a @ref CLocationService
       
   159         * @return The newly created CLocationService object
       
   160         */
       
   161 	    IMPORT_C static CLocationService *NewL() ;
       
   162 
       
   163 	     
       
   164 		 /*
       
   165 		  * @Destructor
       
   166 		  */
       
   167 	    virtual ~CLocationService() ; 
       
   168 
       
   169 	    /**
       
   170 	     * Methods on the  Core Location implementation
       
   171 	     */
       
   172 
       
   173 
       
   174 
       
   175 	    /**
       
   176 	     * Synchronous get location with update options returns current location of the user
       
   177 	     *
       
   178 	     * @param aPosinfobase input TPositionInfoBase object which will hold location details
       
   179 	     * @param aUpdateOpts updateoptions for synchronous calls 
       
   180 	     */
       
   181 	    IMPORT_C TInt GetLocationL( TPositionInfoBase* aPos ,
       
   182 	    							const TPositionUpdateOptions* aUpdateOpts= NULL ) ;
       
   183 	    							
       
   184 
       
   185 	    /**
       
   186 	     * Gets the current location of user asynchronosly calls the users callback handle on reciving 
       
   187 	     * location updates
       
   188 	     * @param aCallBack callback object after reciving the position updates 
       
   189 	     * @param aLocationInfoCategory specifying one of the enumeration in TLocationInfoType.
       
   190 	     * @param aFieldIdList specifies field of HPositionGenericInfo that user intend to retrieve.
       
   191 	     * @param aUpdateoptions update options for asynchronous requests.
       
   192 	     * @see Lsbcommon.h for details of TPositionFieldIdList and TPositionUpdateOptions
       
   193 	     */
       
   194 	    IMPORT_C TInt GetLocationL( MLocationCallBack* aCallBackObj ,
       
   195 	    							TInt aLocationInfoCategory = 0, 
       
   196 	    							TPositionFieldIdList aFieldIdList = NULL ,
       
   197 	    							const TPositionUpdateOptions* aUpdateopts = NULL
       
   198 	    							 );
       
   199 	    							
       
   200 	    /**
       
   201 	     * Gets module information of the Positioning module specified my aModuleId
       
   202 	     *
       
   203 	     * @param TPositionModuleId param to store the obtained module information
       
   204 	     *
       
   205 	     * @see lsbcommon.h for details of TPositionModuleInfoBase
       
   206 	     */								
       
   207 	    IMPORT_C TInt GetModuleInfo( TPositionModuleInfoBase& aModuleInfo ) const ;	
       
   208     
       
   209 	    /**
       
   210 	     * Performs mathoperations (move,distance,bearingto) by parsing contents of input param
       
   211 	     *							
       
   212 	     * @param aInput input paramater for math opertaions
       
   213 	     * 
       
   214 	     * @see inparam in this file for detailed math operation list
       
   215 	     */
       
   216 	       							
       
   217 
       
   218 	    IMPORT_C TInt MathOperation( inpparam& aInput );
       
   219 
       
   220 	    /**
       
   221 	     * Trace function traces users location changes any change in users current location is notificed 
       
   222 	     * to user via call back function
       
   223 	     *
       
   224 	     * @param aCallBackObj callback object after reciving location updates 
       
   225 	     * @param aLocationInfoCategory specifying one of the enumeration in TLocationInfoType.
       
   226 	     * @param aFiledList List of position fields that should be retrived 
       
   227 	     * @param aUpdateOptions update options for trace
       
   228 	     *
       
   229 	     * @see Lsbcommon.h for details of TPositionFieldIdList and TPositionUpdateOptions
       
   230 	     */ 
       
   231 
       
   232 	    IMPORT_C TInt TraceL(MLocationCallBack* aCallBackObj , 
       
   233 	    						TInt aLocationInfoCategory = 0,
       
   234 	    						TPositionFieldIdList aFiledList = NULL ,
       
   235 	    						const TPositionUpdateOptions* aUpateOptions= NULL );
       
   236 	    						
       
   237 
       
   238 	    /**
       
   239 	     * Method to cancell pending async request
       
   240 	     * 
       
   241 	     * aCancelparam cancellation type (trace,getlocation)
       
   242 	     *
       
   243 	     * @see TCancelParam for cancellation options
       
   244 	     */
       
   245 
       
   246 	     IMPORT_C TInt CancelOnGoingService( TInt aCancelparam ) ;
       
   247 	    
       
   248 	    /**
       
   249 	     * Method to fetch last known location from location server
       
   250 	     */
       
   251 
       
   252 	     TInt GetLastKnownLoc( TPosition& aResultPos ) ; 
       
   253 
       
   254 
       
   255 
       
   256 
       
   257 
       
   258     protected:
       
   259 	    /**
       
   260 	     * internal method to construct class members 
       
   261 	     */
       
   262 	    void ConstructL() ; 
       
   263 	    
       
   264 	    /**
       
   265 	     * Default constructor 
       
   266 	     */
       
   267 	    CLocationService() ;  
       
   268 	    
       
   269 	    /**
       
   270 	     * Method to initalise class memebers 
       
   271 	     */
       
   272 	    void DoInitialiseL() ;
       
   273 
       
   274 	    private :
       
   275 	    
       
   276 	    /**
       
   277 	     * Subsession used to fetch location information
       
   278 	     */
       
   279 
       
   280 	    RPositioner iPositioner;
       
   281 	    
       
   282 	    /**
       
   283 	     * Session used for getting location information
       
   284 	     */
       
   285 
       
   286 	    RPositionServer iPosServer;
       
   287 	    
       
   288 	    /**
       
   289 	     * Registration table for callbacks
       
   290 	     */
       
   291 	          
       
   292 	    RPointerArray<CGetLoc> iRegTable; 
       
   293 	    TInt iIndex;
       
   294 
       
   295 	    
       
   296 	    /**
       
   297 	     * Module indtifier used by location server for getting location information
       
   298 	     */
       
   299 	    TPositionModuleId iModuleId ; 
       
   300 
       
   301     };
       
   302 
       
   303 
       
   304 #endif // LOCATIONSERVICE_H