networkprotocolmodules/networkprotocolmodule/LbsProtocolModule/inc/cmtlrstatemachine.h
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     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 // This file defines the class for the MT-LR protocol state machine.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21  @test
       
    22 */
       
    23 
       
    24 #ifndef __CMTLRSTATEMACHINE_H__
       
    25 #define __CMTLRSTATEMACHINE_H__
       
    26 
       
    27 #include "cstatemachinebase.h"
       
    28 
       
    29 
       
    30 /** MT-LR protocol state machine.
       
    31 This class manages the MT-LR protocol procedure and is employed when the protocol
       
    32 module is required to handle interactions for a mobile terminate locate request.
       
    33 
       
    34 The class implements the pure virtual methods defined by CStateMachineBase.
       
    35 @see CStateMachineBase
       
    36 
       
    37 The class also implements a timer observer interface defined by MLbsCallbackTimerObserver
       
    38 @see MLbsCallbackTimerObserver
       
    39 */
       
    40 NONSHARABLE_CLASS(CMtLrStateMachine) : public CStateMachineBase, public MLbsCallbackTimerObserver
       
    41 	{
       
    42 public:
       
    43 
       
    44 	/** MT-LR specific states
       
    45 	These are specific to MT-LR and identify the current state within the
       
    46 	MT-LR protocol procedure.
       
    47 	*/
       
    48 	enum TMtLrState
       
    49 		{
       
    50 		/** Not valid */
       
    51 		EStateNull,
       
    52 		/** Network request received */
       
    53 		EStateNetReqRecvd,
       
    54 
       
    55 		/** LBS Privacy session started */
       
    56 		EStatePrivacySessStarted,
       
    57 		/** LBS Privacy response received - no measurement control yet */
       
    58 		EStatePrivacyRespRecvd,
       
    59 		/** LBS Privacy response received - after measurement control */
       
    60 		EStatePrivacyRespRecvdAfterMeasure,
       
    61 		/** LBS Privacy rejected - no measurement control yet */
       
    62 		EStatePrivacyReject,
       
    63 		/** LBS Privacy response received - after measurement control */
       
    64 		EStatePrivacyRejectAfterMeasure,
       
    65 
       
    66 		/** Measurement control received from the network */
       
    67 		EStateMeasureDataRecvd,
       
    68 		/** Network reference location sent to LBS */
       
    69 		EStateNetBasedLocSent,
       
    70 		/** Network location request received (and sent to LBS) */
       
    71 		EStateLocReqByNet,
       
    72 		/** Location response received from LBS */
       
    73 		EStateLocRespRecvd,
       
    74 		/** Location response sent to network */
       
    75 		EStateLocSentToNet,
       
    76 
       
    77 
       
    78 		/** LBS Client session about to close - after measure control */
       
    79 		EStateClientSessToCloseAfterMeasure,
       
    80 		/** LBS Client session about close to then wait for measure control */
       
    81 		EStateClientSessToCloseWaitMeasure,
       
    82 		/** LBS Client session about close to then wait for location response */
       
    83 		EStateClientSessToCloseWaitLocResp,
       
    84 
       
    85 		/** LBS Client and network sessions closed */
       
    86 		EStateSessionsClosed,
       
    87 
       
    88 		/** Protocol procedure is cancelling */
       
    89 		EStateCancelling
       
    90 
       
    91 		};
       
    92 
       
    93 	/** Request identifiers used when a request is queued.
       
    94 	*/
       
    95 	enum TMtLrQueue
       
    96 		{
       
    97 		/** Privacy response received from LBS */
       
    98 		EQueuePrivacyResponse	 = 100,
       
    99 		/** Location response received from LBS */
       
   100 		EQueueLocResponse		 = 200,
       
   101 		/** Measurement control received from network */
       
   102 		EQueueMeasurementControl = 300
       
   103 		};
       
   104 
       
   105 public:
       
   106 
       
   107 	static CMtLrStateMachine* NewL(MStateMachineObserver& aObserver);
       
   108 	virtual ~CMtLrStateMachine();
       
   109 	
       
   110 	CMtLrStateMachine::TMtLrState CurrentState();
       
   111 
       
   112 	void StartMtLrReqTimer();
       
   113 	void StartMeasureControlTimer();
       
   114 	void StartLocRespTimer();
       
   115 
       
   116 	TBool IsEmergency() const;
       
   117 
       
   118 	TBool IsPrivacyResponseHandled() const;
       
   119 	const TLbsExternalRequestInfo& PrivacyReqInfo() const;
       
   120 	const CLbsNetworkProtocolBase::TLbsPrivacyResponse& PrivacyResponseValue() const;
       
   121 	const TLbsNetPosRequestPrivacy& PrivacyReq() const;
       
   122 	TBool IsRejectedWaitingMeasureControl() const;
       
   123 	
       
   124 	void MtLrReq(const TLbsExternalRequestInfo& aReqInfo,
       
   125 					const TLbsNetPosRequestPrivacy& aPrivacy);
       
   126 	void QueueMtLrReq(const TLbsExternalRequestInfo& aReqInfo,
       
   127 					const TLbsNetPosRequestPrivacy& aPrivacy);
       
   128 	void MtLrCancelInd(TInt aReason);
       
   129 	void PrivacyResp(const CLbsNetworkProtocolBase::TLbsPrivacyResponse& aResponse);
       
   130 
       
   131 	// CStateMachineBase derived methods
       
   132 
       
   133 	void MeasurementControlInd(const TPositionInfoBase& aPosInfo,
       
   134 							const TLbsNetPosRequestQuality& aQuality,
       
   135 							const TLbsNetPosRequestMethod& aPosMethod);
       
   136 	void MeasurementControlErrorInd(TInt aReason);
       
   137 	void NetworkErrorInd();
       
   138 
       
   139 	// CStateMachineBase pure virtual methods
       
   140 	void StartQueuedMachine();
       
   141 	void PreStateTransition();
       
   142 	void StateTransition();
       
   143 	void PostStateTransition();
       
   144 	void CancelProcedure();
       
   145 	void DoQueuedRequest(TInt aRequest);
       
   146 
       
   147 	void LocationResp(TInt aReason, const TPositionInfoBase& aPosInfo);
       
   148 	void MeasurementControlTimeout();
       
   149 
       
   150 	// MLbsCallbackTimerObserver methods
       
   151 	
       
   152 	void OnTimerEventL(TInt aTimerId);
       
   153 	TInt OnTimerError(TInt aTimerId, TInt aError);
       
   154 	
       
   155 protected:
       
   156 
       
   157 	CMtLrStateMachine(MStateMachineObserver& aObserver);
       
   158 	
       
   159 private:
       
   160 	
       
   161 	void ConstructL();
       
   162 	void InitialiseProcedure();
       
   163 	void ProcedureDone();
       
   164 	void CompleteProcedure();
       
   165 
       
   166 	void StorePrivacyReq(const TLbsExternalRequestInfo& aReqInfo, 
       
   167 				const TLbsNetPosRequestPrivacy& aPrivacy);
       
   168 	void StorePrivacyResp(const CLbsNetworkProtocolBase::TLbsPrivacyResponse& iPrivacyResp);
       
   169 
       
   170 protected:
       
   171 	
       
   172 	/** Current MT-LR state
       
   173 	*/
       
   174 	TMtLrState iCurrentState;
       
   175 	
       
   176 	/** Timer for Privacy response required from LBS
       
   177 	*/
       
   178 	CLbsCallbackTimer* iMtLrReqIssuedTimer;
       
   179 	
       
   180 	/** Timer for Measurement Control expected by LBS
       
   181 	*/
       
   182 	CLbsCallbackTimer* iMeasureControlTimer;
       
   183 	
       
   184 	/** Timer for Location response expected by network
       
   185 	*/
       
   186 	CLbsCallbackTimer* iLocRespTimer;
       
   187 
       
   188 	/** Privacy requestor information
       
   189 	*/
       
   190 	TLbsExternalRequestInfo iPrivacyReqInfo;
       
   191 
       
   192 	/** Privacy response
       
   193 	*/
       
   194 	CLbsNetworkProtocolBase::TLbsPrivacyResponse iPrivacyResp;
       
   195 
       
   196 	/** Flag indicates privacy response received
       
   197 	*/
       
   198 	TBool iPrivacyResponseRecvd;
       
   199 
       
   200 	/** Flag indicates privacy response handled
       
   201 	*/
       
   202 	TBool iPrivacyResponseHandled;
       
   203 	
       
   204 	/** Indicates if privacy response arrived before measurement control
       
   205 	*/
       
   206 	TBool iIsPrivacyRespBeforeMeasureControl;
       
   207 
       
   208 	/** Privacy request information
       
   209 	*/
       
   210 	TLbsNetPosRequestPrivacy iPrivacyRequest;
       
   211 
       
   212 	};
       
   213 
       
   214 #endif // __CMTLRSTATEMACHINE_H__
       
   215