networkprotocolmodules/networkprotocolmodule/LbsProtocolModule/inc/cmolrstatemachine.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 // This file defines the class for the MO-LR protocol state machine.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21  @test
       
    22 */
       
    23 
       
    24 #ifndef __CMOLRSTATEMACHINE_H__
       
    25 #define __CMOLRSTATEMACHINE_H__
       
    26 
       
    27 #include "cstatemachinebase.h"
       
    28 
       
    29 
       
    30 /** MO-LR protocol state machine.
       
    31 This class manages the MO-LR protocol procedure and is employed when the protocol
       
    32 module is required to handle interactions for a mobile self-locate.
       
    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(CMoLrStateMachine) : public CStateMachineBase, public MLbsCallbackTimerObserver
       
    41 	{
       
    42 public:
       
    43 
       
    44 	/** MO-LR specific states
       
    45 	These are specific to MO-LR and identify the current state within the
       
    46 	MO-LR self locate protocol procedure.
       
    47 	*/
       
    48 	enum TMoLrState
       
    49 		{
       
    50 		/** Not valid */
       
    51 		EStateNull,
       
    52 		/** LBS Cient MO-LR request has been received */
       
    53 		EStateClientReqRecvd,
       
    54 		/** Network MO-LR session has started */
       
    55 		EStateNetSessStarted,
       
    56 		/** Measurement control data received from the network */
       
    57 		EStateMeasureDataRecvd,
       
    58 		/** Network reference location sent to LBS */
       
    59 		EStateNetBasedLocSent,
       
    60 		/** Network location request sent to LBS */
       
    61 		EStateLocReqByNet,
       
    62 		/** Location response received from LBS */
       
    63 		EStateLocRespRecvd,
       
    64 		/** Location response sent to network */
       
    65 		EStateLocSentToNet,
       
    66 		/** Network MO-LR session about to close */
       
    67 		EStateNetSessToClose,
       
    68 		/** LBS client MO-LR session about to close */
       
    69 		EStateClientSessToClose,
       
    70 		/** Network and LBS sessions closed */
       
    71 		EStateSessionsClosed,
       
    72 		/** Network result location sent to LBS */
       
    73 		EStateNetResultSent,
       
    74 		/** Protocol procedure is to be cancelled */
       
    75 		EStateCancelling
       
    76 		};
       
    77 
       
    78 	/** Request identifiers used when a request is queued.
       
    79 	*/
       
    80 	enum TMoLrQueue
       
    81 		{
       
    82 		/** Location response received from LBS */
       
    83 		EQueueLocResponse		 = 100,
       
    84 		/** Measurement control received from network */
       
    85 		EQueueMeasurementControl = 200,
       
    86 		/** Network result received from network */
       
    87 		EQueueNetworkResult		 = 300,
       
    88 		};
       
    89 
       
    90 public:
       
    91 
       
    92 	static CMoLrStateMachine* NewL(MStateMachineObserver& aObserver);
       
    93 	virtual ~CMoLrStateMachine();
       
    94 	
       
    95 	CMoLrStateMachine::TMoLrState CurrentState();
       
    96 	
       
    97 	void StartMoLrReqTimer();
       
    98 	void StartLocRespTimer();
       
    99 	void StartFacResultTimer();
       
   100 
       
   101 	TBool IsLocReqSentToLbs() const;
       
   102 
       
   103 	const TPositionInfoBase& NetResultLoc() const;
       
   104 
       
   105 	void MoLrReq(const TLbsNetSessionId& aSessionId);
       
   106 	void QueueMoLrReq(const TLbsNetSessionId& aSessionId);
       
   107 	void SessionResult(TInt aResult, const TPositionInfoBase* aPosInfo);
       
   108 
       
   109 	// CStateMachineBase derived methods
       
   110 
       
   111 	void MeasurementControlInd(const TPositionInfoBase& aPosInfo,
       
   112 							const TLbsNetPosRequestQuality& aQuality,
       
   113 							const TLbsNetPosRequestMethod& aPosMethod);
       
   114 	void MeasurementControlErrorInd(TInt aReason);
       
   115 	void NetworkErrorInd();
       
   116 
       
   117 	// CStateMachineBase pure virtual methods
       
   118 	void StartQueuedMachine();
       
   119 	void PreStateTransition();
       
   120 	void StateTransition();
       
   121 	void PostStateTransition();
       
   122 	void CancelProcedure();
       
   123 	void DoQueuedRequest(TInt aRequest);
       
   124 
       
   125 	void LocationResp(TInt aReason, const TPositionInfoBase& aPosInfo);
       
   126 	void MeasurementControlTimeout();
       
   127 
       
   128 	// MLbsCallbackTimerObserver methods
       
   129 	
       
   130 	void OnTimerEventL(TInt aTimerId);
       
   131 	TInt OnTimerError(TInt aTimerId, TInt aError);
       
   132 	
       
   133 	
       
   134 protected:
       
   135 
       
   136 	CMoLrStateMachine(MStateMachineObserver& aObserver);
       
   137 	
       
   138 private:
       
   139 	
       
   140 	void ConstructL();
       
   141 	void InitialiseProcedure();
       
   142 	void CompleteProcedure();
       
   143 
       
   144 	void StoreNetResultLoc(const TPositionInfoBase& aPosInfo);
       
   145 
       
   146 protected:
       
   147 	
       
   148 	/** Current MO-LR state
       
   149 	*/
       
   150 	TMoLrState iCurrentState;
       
   151 	
       
   152 	/** Timer for MO-LR requests issued to network.
       
   153 	*/
       
   154 	CLbsCallbackTimer* iMoLrReqIssuedTimer;
       
   155 	
       
   156 	/** Timer for Location response expected by network
       
   157 	*/
       
   158 	CLbsCallbackTimer* iLocRespTimer;
       
   159 	
       
   160 	/** Timer for Facility result expected from network
       
   161 	*/
       
   162 	CLbsCallbackTimer* iFacResultTimer;
       
   163 	
       
   164 	/** Flag to show location request has been sent to LBS.
       
   165 	*/
       
   166 	TBool iIsLocReqSentToLbs;
       
   167 
       
   168 	/** Flag to indicate if network result location is available
       
   169 	*/
       
   170 	TBool iIsNetResultLocAvailable;
       
   171 	
       
   172 	/** Network Result Position info.
       
   173 	*/
       
   174 	TPositionInfo iNetResultPosInfo;
       
   175 
       
   176 	};
       
   177 
       
   178 #endif // __CMOLRSTATEMACHINE_H__
       
   179