networkprotocolmodules/common/suplrrlpasn1/inc/suplmessagebase.h
changeset 45 15a2125aa2f3
parent 40 18280709ae43
child 49 5f20f71a57a3
child 51 95c570bf4a05
equal deleted inserted replaced
40:18280709ae43 45:15a2125aa2f3
     1 // Copyright (c) 2007-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19  
       
    20 */
       
    21 #ifndef LBS_SUPL_MESSAGE_BASE_H
       
    22 #define LBS_SUPL_MESSAGE_BASE_H
       
    23 
       
    24 #include "suplmessagecommon.h"
       
    25 
       
    26 // forward declarations
       
    27 class TLbsNetPosCapabilities;
       
    28 class TPositionInfoBase;
       
    29 class TCourse;
       
    30 class ASN1T_ULP_PDU;
       
    31 class ASN1C_ULP_PDU;
       
    32 class ASN1PEREncodeBuffer;
       
    33 class ASN1T_SETCapabilities;
       
    34 class ASN1T_Position;
       
    35 class ASN1T_LocationId;
       
    36 class ASN1T_Velocity;
       
    37 
       
    38 
       
    39 /**
       
    40 CSuplMessageBase is an abstract class providing a base definition for SUPL
       
    41 messages either received or constructed for sending. Concrete classes derived 
       
    42 from this class represent each of the supported SUPL message types, and provide
       
    43 methods for accessing and setting their member parameters.
       
    44 
       
    45 When building outgoing messages, the constructor must be called with 
       
    46 aIsOutgoingMessage set to ETrue. This results in the internal data members 
       
    47 necessary for building and encoding an outgoing message.
       
    48 
       
    49 For received messages, the SUPL ASN1 Decoder object (see csuplasn1decoder.h)
       
    50 calls SetDecodedData(), passing the decoded data structures (ownership is passed
       
    51 immediately on entrance to this method). Note that these data structures are 
       
    52 defined by compilation of the SUPL definition using a third party ASN1 compiler
       
    53 and therefore do not conform to standard Symbian naming conventions. 
       
    54 
       
    55 Types encapsulating common parts for operation within the SUPL Protocol Module
       
    56 are described in file suplmessagecommon.h
       
    57 
       
    58 @internalTechnology
       
    59 */
       
    60 NONSHARABLE_CLASS(CSuplMessageBase) : public CBase
       
    61 	{
       
    62 public:
       
    63 	
       
    64 	/** TSuplMessageType typedef */
       
    65 	typedef TUint32 TSuplMessageType;
       
    66 
       
    67 	enum _TSuplMessageType
       
    68 		{	
       
    69 	  	ESuplInit = 0,
       
    70 	  	ESuplStart,
       
    71 	  	ESuplResponse,
       
    72 	  	ESuplPosInit,
       
    73 	  	ESuplPos,
       
    74 	  	ESuplEnd,
       
    75 	  	ESuplAuthReq,
       
    76 	  	ESuplAuthResp,
       
    77 	  	
       
    78 	  	ESuplMessageLimit	
       
    79 		};
       
    80 		
       
    81 protected:
       
    82 	CSuplMessageBase(TSuplMessageType aType, TBool aIsOutgoingMessage);
       
    83 
       
    84 public:
       
    85 	virtual ~CSuplMessageBase();
       
    86 	
       
    87 public:
       
    88 	/** Encode a populated outgoing message */
       
    89 	IMPORT_C TInt EncodeToL(TPtr8& aBuf);
       
    90 	
       
    91 	/** Methods for populating common parameters for outgoing messages */
       
    92 
       
    93 	/** Set the SUPL version used (for outgoing messages) */
       
    94 	IMPORT_C void SetVersion(CSuplVersion& aVersion);
       
    95 
       
    96 	/** Set the SUPL Session ID (for outgoing messages) */
       
    97 	IMPORT_C TInt SetSessionId(CSuplSessionId& aSessionId);
       
    98 	
       
    99 	/** Methods for accessing content of decoded received messages */
       
   100 	
       
   101 	/** Returns the message type */
       
   102 	IMPORT_C CSuplMessageBase::TSuplMessageType MessageType();
       
   103 
       
   104 	/** Populates aVersion with the SUPL version (for received messages) */
       
   105 	IMPORT_C TInt GetVersion(CSuplVersion& aVersion);
       
   106 
       
   107 	/** Populates aSessionId with the SUPL Session ID (for received messages) */
       
   108 	IMPORT_C TInt GetSessionId(CSuplSessionId& aSessionId);
       
   109 	
       
   110 	/** Prints the content of the data structure to the logger */
       
   111 	IMPORT_C void LogMessageContent();
       
   112 
       
   113 public:
       
   114 	/** Assign decoded ASN1 data. (for received messages) 
       
   115 	    Not intended for DLL export */
       
   116 	void SetDecodedData(ASN1T_ULP_PDU* aData, ASN1C_ULP_PDU* aControl);
       
   117 
       
   118 private:
       
   119 	/** Prohibit copy constructor */
       
   120 	CSuplMessageBase(const CSuplMessageBase&);
       
   121 
       
   122 	/** Prohibit assigment operator */
       
   123 	CSuplMessageBase& operator= (const CSuplMessageBase&);
       
   124 	
       
   125 protected:
       
   126 	/** second stage constructor */
       
   127 	void ConstructL();
       
   128 
       
   129 	/** checks for memory allocation failure and leaves */
       
   130 	void LeaveIfAllocErrorL();
       
   131 	
       
   132 	/** translates ASN1 run-time errors */
       
   133 	TInt ProcessAsn1Error(TInt aError);
       
   134 	
       
   135 	/** methods for outgoing SUPL parameters common to multiple messages */
       
   136 	TInt PopulateSetCapabilities(const TLbsNetPosCapabilities& aCapsSource, ASN1T_SETCapabilities& aCapsTarget);
       
   137 	TInt PopulateLocationId(const CSuplLocationId& aLocSource, ASN1T_LocationId& aLocTarget);
       
   138 	TInt PopulatePosition(const TPositionInfoBase& aPosSource, ASN1T_Position& aPosTarget);
       
   139 	TInt PopulateVelocity(const TCourse& aCourse, ASN1T_Velocity& aVelTarget);
       
   140 	
       
   141 	/** common calculation methods */
       
   142 	TInt Uncertainty(const TReal32& aDistance);
       
   143 	TInt UncertaintyAltitude(const TReal32& aDistance);
       
   144 	TInt EncodeAltitude(const TReal32& aAltitude);
       
   145 
       
   146 protected:
       
   147 	// Message type identifier
       
   148 	TSuplMessageType iSuplMessageType;
       
   149 	
       
   150 	TBool iIsOutgoingMessage;
       
   151 
       
   152 	// SUPL message data structure and C++ management class for the data.
       
   153 	ASN1T_ULP_PDU* iData;
       
   154 	ASN1C_ULP_PDU* iControl;		
       
   155 
       
   156 	// Buffer management object for encoding ASN.1 PER data stream
       
   157 	ASN1PEREncodeBuffer* iEncodeBuffer;
       
   158 	
       
   159 	// Buffer for storing timestamp translated to UTC format YYMMDDhhmmssZ
       
   160 	TBuf8<13> iUtcTime; 
       
   161 	};
       
   162 
       
   163 #endif // LBS_SUPL_MESSAGE_BASE_H