supl/locationomasuplprotocolhandler/protocolhandlerver1/inc/epos_comasuplposinitstate.h
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:   class for handling SUPL_POS_INIT message...
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_COMASUPLPOSINITSTATE_H
       
    21 #define C_COMASUPLPOSINITSTATE_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 #include "epos_comasuplstartstate.h"
       
    26 #include "epos_comasuplsession.h"
       
    27 #include "epos_comasuplasnbase.h"
       
    28 
       
    29 class COMASuplSETCapabilities;
       
    30 class RMobilePhone;
       
    31 class COMASuplPOSRequestor;
       
    32 class COMASuplReqAsstData;
       
    33 class COMASuplPosition;
       
    34 class COMASuplPosPayload;		
       
    35 class COMASuplVelocity;
       
    36 
       
    37 /**
       
    38  *  COMASuplPosInitState handles all SUPL_POS_INIT related processing.  
       
    39  *  @lib eposomasuplprotocolhandler.lib
       
    40  *  @since S60 v3.1u
       
    41  */
       
    42 
       
    43 class COMASuplPosInitState : public COMASuplStartState
       
    44 {
       
    45 	public :  // Constructor 
       
    46 	
       
    47 		/**
       
    48 		* NewL Method.
       
    49 		* @since S60 v3.1u
       
    50 		* @param aCapabilities,Allowed Capabilities
       
    51 		* @param aMobilePhone,
       
    52 		* @param aMsgTimeout,Timeout for message
       
    53 		* @return Instance of COMASuplPosInitState
       
    54 		*/ 
       
    55 		static COMASuplPosInitState* NewL(COMASuplSETCapabilities* aCapabilities,
       
    56 										  RMobilePhone& aMobilePhone,TInt aMsgTimeout,
       
    57 										  COMASuplPOSRequestor* aPosRequestor,TInt aAllowedCapabilities,
       
    58 										  COMASuplSession::TOMASuplReqType aRequestType, TOMASuplPosMethod aPosMethod,COMASuplAsnHandlerBase* aOMASuplAsnHandlerBase,
       
    59 										  HBufC8* aEncodedSuplInit = NULL,
       
    60 										  HBufC8* aHSLPAddress = NULL);
       
    61 		
       
    62 		/**
       
    63 		* Destructor.
       
    64 		*/
       
    65 		~COMASuplPosInitState();
       
    66 		
       
    67     public:		//COMASuplState
       
    68     
       
    69     /**
       
    70 		* GenerateMessageL Method,Generates message...which message to be generate will be depend on derived class implementation
       
    71 		* @since S60 v3.1u
       
    72 		* @param None
       
    73 		* @return System wide error
       
    74 		*/ 
       
    75 		virtual TInt GenerateMessageL();
       
    76 
       
    77     	/**
       
    78 		* EncodeMessageL Method,Encodes message...which message to be generate will be depend on derived class implementation
       
    79 		* @since S60  v3.1u
       
    80 		* @param aSuplVersion, version of SUPL
       
    81 		* @param aSessionId, sessionid of session.
       
    82 		* @param aError, error code if any error occures while conversion.
       
    83 		* @return encoded data, HBufC8*
       
    84 		*/ 
       
    85 		virtual HBufC8* EncodeMessageL(TOMASuplVersion &aSuplVersion,
       
    86 									   COMASuplSessionID* aSessionId,TInt &aError);
       
    87 									 
       
    88 	   /**
       
    89 		* GetPosParamsL,Retrive Optional parameters for
       
    90 		* SUPL POS INIT Message from POS Message plug-in
       
    91 		* @since S60  v3.1u
       
    92 		*/ 
       
    93 		virtual void GetPosParamsL();
       
    94 		
       
    95 		void CancelOperation();
       
    96 		
       
    97 	public: // From MOMASuplMsgStateObserver
       
    98 	
       
    99 		/**
       
   100 		* OperationCompleteL,Notifies about complaetion of operation with or without error.
       
   101 		*@since Series 60 3.1u
       
   102 		*@param aError,error code occured while completion of operation.
       
   103 		*/
       
   104 		virtual void OperationCompleteL(TInt aError);
       
   105 		
       
   106 		/**
       
   107 		* GetPositionComplete,Notifies about complaetion of operation with or without error.
       
   108 		*@since Series 60 3.1u
       
   109 		*@param None
       
   110 		*/
       
   111 		void GetPositionComplete(TInt /*aError*/);
       
   112 		
       
   113 		
       
   114 	public: //From MOMASuplETelObserver
       
   115 
       
   116 	    /**
       
   117 	     * RequestCompleted Method, Location Id request for comparision completed succesfully
       
   118 	     * @since S60 v3.1u
       
   119 	     * @param aLocationId, all location related information
       
   120 	     * @param aErrorCode, Failure reason code        
       
   121 	     * @return None
       
   122 	     */
       
   123 	    void ComparisionLocationIDRequestCompletedL(COMASuplLocationId* aLocationId,TInt aErrorCode);
       
   124 		
       
   125 	public:	
       
   126 		/**
       
   127 		* IsGenerationInProgress,returns status of generation of message
       
   128 		*@since Series 60 3.1u
       
   129 		*@param None
       
   130 		@retun TBool
       
   131 		*/
       
   132 		TBool IsGenerationInProgress();
       
   133 		
       
   134 		/**
       
   135 		*GetRemainingPospayLoadL,Gets the remaining Pospayload (i.e.more than 8 kb...used for sending with SUPL_POS) 
       
   136 		*Callee gets ownership....
       
   137 		*@since Series 60 3.1
       
   138 		*@param None
       
   139 		@retun COMASuplPosPayload*
       
   140 		*/
       
   141 		
       
   142 		COMASuplPosPayload* GetRemainingPospayLoadL();
       
   143 
       
   144 		/**
       
   145 		*IsPosPayloadPresent,Checks if POSPayload is present in POSINIT
       
   146 		*Callee gets ownership....
       
   147 		*@since Series 60 3.1
       
   148 		*@param None
       
   149 		@retun TBool
       
   150 		*/
       
   151 		TBool IsPosPayloadPresent();
       
   152 		
       
   153 	private : 
       
   154 	
       
   155 	    //Constuctor
       
   156 		COMASuplPosInitState(COMASuplSETCapabilities* aCapabilities,RMobilePhone& aMobilePhone,
       
   157 							 TInt aMsgTimeout, COMASuplPOSRequestor* aPosRequestor,COMASuplSession::TOMASuplReqType aRequestType,COMASuplAsnHandlerBase* aOMASuplAsnHandlerBase);
       
   158         /**
       
   159         * ConstructL Method, 2nd phase construction
       
   160         * @since S60  v3.1u
       
   161         * @param None
       
   162         * @return None
       
   163         */
       
   164 		void ConstructL(TInt aAllowedCapabilities, TOMASuplPosMethod aPosMethod, HBufC8* aEncodedSuplInit = NULL, HBufC8 *aHSLPAddress = NULL);
       
   165 		
       
   166 		/**
       
   167         * ValidateSetCapabilities Method to validate the capabilities of
       
   168         * the SET against the Capabilities retrieved during the construction
       
   169         * of SUPL POS INIT
       
   170         * @since S60  v3.1u
       
   171         * @param None
       
   172         * @return None
       
   173         */
       
   174 		TInt ValidateSetCapabilities();
       
   175 
       
   176 	
       
   177 		/**
       
   178 		* ComputeCapabilities Method,Computes capabilities.. does SETCaps = SETCaps & AllowedCaps
       
   179 		* @since S60 v3.1u
       
   180 		* @param None
       
   181 		* @return None
       
   182 		*/
       
   183 		void ComputeCapabilities();
       
   184 		
       
   185 		/**
       
   186 		* UpdateCapabilities modfies capability if 
       
   187 		* @since S60 v3.1u
       
   188 		* @param None
       
   189 		* @return None
       
   190 		*/
       
   191 		void UpdateCapabilities(); 
       
   192 		/**
       
   193 		* ComputeSuplInitVerL Method,Computes the Verof SUPL INIT
       
   194 		* in case of Network Initiated Location requests.
       
   195 		* @since S60 v3.1u
       
   196 		* @param None
       
   197 		* @return None
       
   198 		*/
       
   199 		
       
   200 		TBool ComputeSuplInitVerL();
       
   201         /**
       
   202 		* StartTimer Method, Starts timer...
       
   203 		* @since Series 60 3.1u
       
   204 		* @param None
       
   205 		* @return None
       
   206 		*/ 
       
   207 		void StartTimer();
       
   208 		
       
   209         /**
       
   210 		* StripPospayLoadL Method, Strips Pospayload data if it exceeds more than 8KB
       
   211 		* @since Series 60 3.1
       
   212 		* @param  None
       
   213 		* @return None
       
   214 		*/ 
       
   215 		void StripPospayLoadL();		
       
   216 
       
   217 	private://Logging
       
   218 		void LogPosPayloadData();
       
   219 		void LogSETCapabilities();
       
   220 		void LogPosition();
       
   221 		void LogReqAssistanceData();
       
   222 		void LogVelocity(COMASuplVelocity* velocity);
       
   223 		void LogPacket(const TDesC8& aPacket);
       
   224 		void PrintHex(const TDesC8& aBuffer,TInt aLine);
       
   225 	private : //Data
       
   226 	
       
   227 		
       
   228 		COMASuplSETCapabilities *iCurSetCapabilities;
       
   229 		
       
   230 		COMASuplSETCapabilities* iOldCapabilities;
       
   231 		
       
   232 		COMASuplReqAsstData *iReqAsstData;
       
   233 		
       
   234 		COMASuplPosition *iPosition;
       
   235 		
       
   236 		COMASuplPosPayload *iPosPayload;
       
   237 		
       
   238 		COMASuplVelocity *iVelocity;
       
   239 				
       
   240 		COMASuplSession::TOMASuplReqType iRequestType;
       
   241 			
       
   242 		HBufC8 *iEncodedSuplInit;
       
   243 		
       
   244 		HBufC8 *iHSLPAddress;
       
   245 		
       
   246 		TBuf8<64> iRes;
       
   247 		
       
   248 		TBool iVerPresent;
       
   249 
       
   250         TBool iPosPayloadPresent;
       
   251         
       
   252         COMASuplPosPayload* iRemainingPospayload;
       
   253         
       
   254         //Flag to indicate that the position data has to be ignored
       
   255         TBool   iIgnorePosData;
       
   256         //Flag to indicate fetching of pos data was repeated due to change in cell id 
       
   257         TBool   iRepeatedPosDataFetch;
       
   258 
       
   259     	COMASuplPosSessionBase::TOMASuplPositioningMethod iPosMethod;
       
   260 };
       
   261 
       
   262 
       
   263 #endif // C_COMASUPLPOSINITSTATE_H