locationmgmt/agpslocationmgr/inc/lbslocationrequesthandler.h
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // locationrequesthandler.h
       
    15 // Definition of location request handler sub-component of agps manager
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22 */
       
    23 
       
    24 #ifndef LBSLOCREQHANDLER_H
       
    25 #define LBSLOCREQHANDLER_H
       
    26 
       
    27 #include <e32base.h>
       
    28 
       
    29 #include "LbsInternalInterface.h"
       
    30 #include "lbstimer.h"
       
    31 
       
    32 #include <lbs/lbslocdatasourcegpsbase.h>
       
    33 
       
    34 class MLocationRequestHandlerObserver
       
    35 	{
       
    36 public:
       
    37 
       
    38 	enum TRequestStateChangeReason
       
    39 		{
       
    40 		EReasonNone,
       
    41 		EReasonRequest,
       
    42 		EReasonCancel,
       
    43 		EReasonTimeout
       
    44 		};
       
    45 
       
    46 	virtual void OnLocationRequestStateChanged(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel,const TRequestStateChangeReason& aReason) = 0;
       
    47 	virtual void OnSystemStatusAdvice(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel, TBool aTracking) = 0;
       
    48 	virtual void OnPowerModeAdvice(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel, CLbsLocationSourceGpsBase::TPowerMode& aPowerMode) = 0;
       
    49 
       
    50 	};
       
    51 	
       
    52 	
       
    53 class CLocationRequestHandler :	public CActive, private MLbsCallbackTimerObserver
       
    54 	{
       
    55 public:
       
    56 	
       
    57 	enum TRequestState
       
    58 		{
       
    59 		EIdle,
       
    60 		EActive,
       
    61 		EActiveRestartOnTargetTime
       
    62 		};
       
    63 		
       
    64 	static CLocationRequestHandler* NewL(MLocationRequestHandlerObserver& aObserver, const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel);
       
    65 	~CLocationRequestHandler();
       
    66 
       
    67 	TBool IsAccuracyRequirementMet(TReal32 aHorizontalAccuracy, TReal32 aVerticalAccuracy);
       
    68 
       
    69 	void RestartOnTargetTime();
       
    70 	TBool IsRequestActive() const;
       
    71 	void InvalidateRequest();
       
    72 	
       
    73 	//void RestartOnTargetTime();
       
    74 	void CancelRestartOnTargetTime();
       
    75 	
       
    76 	TTime GetStartTime() const ;
       
    77 	TTime GetTimeActivated() const;
       
    78 	TLbsLocRequestQualityInt GetQuality() const ;
       
    79 	TBool GetNewClient() const ;
       
    80 	TPositionModuleInfo::TTechnologyType GetTechnologyTypeFromRequest(TInt aIndex) const;
       
    81 	TBool GpsTimingOfCellFramesRequested() const;
       
    82 
       
    83 private:
       
    84 	CLocationRequestHandler(MLocationRequestHandlerObserver& aObserver,	const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel); 
       
    85 	void ConstructL(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel);
       
    86 
       
    87 	// From CActive
       
    88 	virtual void RunL();
       
    89 	virtual void DoCancel();
       
    90 	virtual TInt RunError(TInt aError);
       
    91 	
       
    92 	// From MLbsCallbackTimerObserver
       
    93 	void OnTimerEventL(TInt aTimerId);
       
    94 	TInt OnTimerError(TInt aTimerId, TInt aError);
       
    95 
       
    96 	// Helpers
       
    97 	void ActivateRequest();
       
    98 	void CompleteSelf(TInt aReason);
       
    99 	void ProcessAnyOutstandingRequestL();
       
   100 	void ProcessSystemStatusAdvice(TLbsPositionUpdateRequestBase& aRequest);
       
   101 	void ProcessPowerModeAdvice(TLbsPositionUpdateRequestBase::TPowerAdvice aMode);
       
   102 
       
   103 private:
       
   104 	MLocationRequestHandlerObserver& iObserver;
       
   105 	RLbsPositionUpdateRequests iposUpdateReq;
       
   106 	RLbsPositionUpdateRequests::TChannelIdentifer iChannel;
       
   107 	TLbsPositionUpdateRequest iRequest;
       
   108 	TRequestState iRequestState;
       
   109 	
       
   110 	CLbsCallbackTimer*	iTimer;
       
   111 	
       
   112 	// Stores the actual start time for immediate reqs
       
   113 	// Needed when calculating max fix time for a combined request
       
   114 	TTime	iRequestActivationTime;
       
   115 
       
   116 	TBool iLastRequestWasCancel;
       
   117 	};
       
   118 
       
   119 #endif // LBSLOCREQHANDLER_H
       
   120