networkprotocolmodules/suplcontrolplaneprotocols/suplpositioningprotbase/inc/suplpositioningprotocolfsm.h
branchRCL_3
changeset 65 a796fdeeb33c
parent 58 87622fad6b51
equal deleted inserted replaced
58:87622fad6b51 65:a796fdeeb33c
     1 // Copyright (c) 2008-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 base class and observer to allow a SUPL protocol
       
    15 // to send/receive messages to/from positioning protocol state machines.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalTechnology
       
    22  
       
    23 */
       
    24 
       
    25 #ifndef CSUPLPOSITIONINGPROTOCOLFSM_H
       
    26 #define CSUPLPOSITIONINGPROTOCOLFSM_H
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <lbs/lbslocdatasourcegpsbase.h>
       
    30 #include <lbs/lbsassistancedatabuilderset.h>
       
    31 #include <lbspositioninfo.h>
       
    32 #include <lbs/lbsloccommon.h>
       
    33 #include "lbstimer.h"
       
    34 #include <lbs/lbsnetcommon.h>
       
    35 #include <lbs/lbsnetprotocolbase.h>
       
    36 #include "suplpos.h"
       
    37 
       
    38 
       
    39 class CStateHandlerBase;
       
    40 
       
    41 /** Positioning Protocol observer mixin definition.
       
    42 	This defines an interface to be implemented by an observer of the Positioning Protocol.
       
    43 	The SUPL state machines implement this.
       
    44 */
       
    45 class MSuplPositioningProtocolFsmObserver
       
    46 	{
       
    47 public:
       
    48 		
       
    49 	/** Pass assistance data to the observer.
       
    50 	@return
       
    51 	*/
       
    52 	virtual void ProcessAssistanceData(const TLbsAsistanceDataGroup& aGroupMask, TInt aReason)= 0;
       
    53 	
       
    54 	/** Send a positioning request to the observer.
       
    55 	*/
       
    56 	virtual void ProcessPositioningRequest(const TLbsNetPosRequestQuality& aQuality,
       
    57 										   const TLbsNetPosRequestMethod& aPosMethod) = 0;
       
    58 
       
    59 	/** Request from the observer that a SUPL POS is sent to the SLP with the provided payload
       
    60 	*/						
       
    61 	virtual void PositioningPayloadToNetwork(const CSuplPosPayload* aPositioningPayload) = 0;
       
    62 	
       
    63 	/** Inform the observer that there has been an error in the positioning protocol. Expected
       
    64 	action is termination of the SUPL session via SUPL END.
       
    65 	*/
       
    66 	virtual void PositioningProtocolError(const TInt& aError) = 0;
       
    67 	
       
    68 	/** Inform observer that the Positioning session has finished **/
       
    69 	virtual void PositioningSessionEnded() = 0;
       
    70 	};
       
    71 
       
    72 
       
    73 //-----------------------------------------------------------------------------
       
    74 // Positioning Protocol State Machine Base Class
       
    75 //-----------------------------------------------------------------------------
       
    76 
       
    77 /** Base class definition for positioning protocol state machines.
       
    78 This class provides support for common features of all state machines
       
    79 of positioning protocols associated to SUPL.
       
    80 
       
    81 A significant aspect incorporated in this base class is the active object
       
    82 mechanism for performing state transitions. This feature is used to provide
       
    83 state machines with the ability to perform autonomous and asynchronous actions
       
    84 e.g. to receive a indication of positioning protocol messages arriving from the
       
    85 network and to perform interactions with SUPL state machines.
       
    86 
       
    87 The base class includes various attributes that describe protocol activity,
       
    88 together with access methods used to retrieve the value of these attributes.
       
    89 */
       
    90 class CSuplPositioningProtocolFsm : public CActive
       
    91 	{
       
    92 public:
       
    93 
       
    94 	/** State machine protocol state.
       
    95 	This defines the general protocol state for state machines.
       
    96 	*/
       
    97 	enum TPositioningProtocolState
       
    98 		{
       
    99 		/** Not valid */
       
   100 		EStateNull,
       
   101 		/** Ready to use, but not currently active. */
       
   102 		EStateReady,
       
   103 		/** Actively performing a protocol procedure.*/
       
   104 		EStateActive,
       
   105 		/** In the process of cancelling. */
       
   106 		EStateCancelling
       
   107 		};
       
   108 
       
   109 	/** State machine cancel source.
       
   110 	This defines the source of a cancellation.
       
   111 	*/
       
   112 	enum TCancelSource
       
   113 		{
       
   114 		/** Not cancelling */
       
   115 		ECancelNone,
       
   116 		/** The SUPL FSM cancelled the procedure */
       
   117 		ESuplFsmCancel,
       
   118 		/** A network error occurred */
       
   119 		ECancelNetworkError,
       
   120 		/** A network timeout occurred */
       
   121 		ECancelNetworkTimeout,
       
   122 		/** State machine is closing down (destruction)*/
       
   123 		ECancelClosing
       
   124 		};
       
   125 
       
   126 
       
   127 public:
       
   128 	
       
   129 	virtual ~CSuplPositioningProtocolFsm();
       
   130 
       
   131 	// CActive derived methods
       
   132 	void RunL() = 0;
       
   133 	void DoCancel() = 0;
       
   134 	
       
   135 	// Methods that must be overriden in derived classes
       
   136 	virtual void ProcessPositioningMessage(CSuplPosPayload* aMessage) = 0;
       
   137 	virtual void CancelMachine(const TCancelSource& aCancelSource, TInt aReason) = 0;
       
   138 	virtual void AssistanceDataRequest(const TLbsAssistanceDataGroup& aMask) = 0;
       
   139 	virtual void LocationResp(TInt aReason, const TPositionInfoBase& aPosInfo) = 0;
       
   140 	virtual bool IsAssistDataRequestAllowed() = 0; 
       
   141 
       
   142 protected:
       
   143 
       
   144 	CSuplPositioningProtocolFsm(MSuplPositioningProtocolFsmObserver& aObserver);
       
   145 	
       
   146 protected:
       
   147 
       
   148 	/** Reference to State machine observer
       
   149 	*/
       
   150 	MSuplPositioningProtocolFsmObserver& iObserver;
       
   151 	};
       
   152 
       
   153 #endif // CSUPLPOSITIONINGPROTOCOLFSM_H