mapnavproviderrefapp/inc/mnrppositionrequest.h
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     1 /*
       
     2 * Copyright (c) 2006 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:  CMnrpPositionRequest class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MNRP_POSITION_REQUEST_H_
       
    20 #define MNRP_POSITION_REQUEST_H_
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <lbs.h>
       
    24 
       
    25 class TPositionUpdateOptions;
       
    26 
       
    27 /** Position observer */
       
    28 class MMnrpPositionObserver
       
    29     {
       
    30     public:
       
    31         virtual void HandlePositionRequestCompletedL( TInt aError ) =0;
       
    32     };
       
    33 
       
    34 /** Provides an interface for retrieving the current location.
       
    35  */
       
    36 class CMnrpPositionRequest: public CActive
       
    37     {
       
    38     public: 
       
    39 
       
    40         /** Creates new instance of request
       
    41         * @param aAppName the name of this application
       
    42         * @param aObserver observer to callback when locations are retrieved
       
    43         */
       
    44         IMPORT_C static CMnrpPositionRequest* NewL(
       
    45             const TDesC& aRequestorName,
       
    46             MMnrpPositionObserver& aObserver);
       
    47 
       
    48         IMPORT_C ~CMnrpPositionRequest();
       
    49 
       
    50     public: 
       
    51 
       
    52         /**
       
    53          * Starts the fetching of a location. In the first place the default 
       
    54          * proxy is used for retrieving a location. If fetching default location
       
    55          * fails the last known location is fetched. If fetching last known 
       
    56          * location fails, an error code is returned to the observer.
       
    57          *
       
    58          * @param aLastKnownLocationAllowed whether last know location is allowed
       
    59          */
       
    60         IMPORT_C void FetchNewPosition( TBool aLastKnownLocationAllowed = EFalse );
       
    61 
       
    62  		/** Returns current location */
       
    63         IMPORT_C void GetPosition( TPositionInfo& aPosition );
       
    64 
       
    65  		/** Returns current speed info */
       
    66         IMPORT_C TReal32 Speed();
       
    67 
       
    68  		/** Returns current heading info */
       
    69         IMPORT_C TReal32 Heading();
       
    70 
       
    71  		/** Returns current magnetic heading info */
       
    72         IMPORT_C TReal32 MagneticHeading();
       
    73 
       
    74  		/** Returns current course info */
       
    75         IMPORT_C TReal32 Course();
       
    76 
       
    77  		/** Returns current magnetic course info */
       
    78         IMPORT_C TReal32 MagneticCourse();
       
    79 
       
    80 		/** Modifies options for the next request */
       
    81         IMPORT_C void SetOptionsL( const TPositionUpdateOptionsBase& aOptions );
       
    82 
       
    83     protected: // from CActive
       
    84 
       
    85         void DoCancel();
       
    86         void RunL();
       
    87         TInt RunError(TInt aError);
       
    88 
       
    89     private:
       
    90 
       
    91         CMnrpPositionRequest( MMnrpPositionObserver& aObserver );
       
    92         void ConstructL( const TDesC& aAppName );
       
    93 
       
    94         /** Issues new request for location retrieval. */
       
    95         void ExecuteNextStep();
       
    96 
       
    97         void InitContainer( HPositionGenericInfo& aGenericInfo );
       
    98         void SaveContainer( const HPositionGenericInfo& aGenericInfo );
       
    99 
       
   100     private:
       
   101 
       
   102         /**
       
   103         * TState defines the different states this object may enter.
       
   104         */
       
   105         enum TState 
       
   106             {
       
   107             EIdle,
       
   108             EAcquiringDefaultLocation,
       
   109             EAcquiringLastKnownLocation
       
   110             };
       
   111 
       
   112     private: 
       
   113 
       
   114         //! Contains the location
       
   115         HPositionGenericInfo* iGenericPosition;
       
   116         
       
   117         //! Local storage for last location info
       
   118         TPositionInfo iPositionInfo;
       
   119         TReal32 iSpeed;
       
   120         TReal32 iHeading;
       
   121         TReal32 iMagneticHeading;
       
   122         TReal32 iCourse;
       
   123         TReal32 iMagneticCourse;
       
   124 
       
   125         //! The observer to callback when location retieval is ready
       
   126         MMnrpPositionObserver& iObserver;
       
   127 
       
   128         //! Reference to the Location Server session
       
   129         RPositionServer iLocationServer;
       
   130 
       
   131         //! Reference to the Location Server subsession
       
   132         RPositioner iPositioner;
       
   133         
       
   134         TBool iLastKnownLocationAllowed;
       
   135 
       
   136         //! The current state this object has entered
       
   137         TState iState;
       
   138     };
       
   139 
       
   140 #endif // MNRP_POSITION_REQUEST_H_
       
   141