realtimenetprots/sipfw/SIP/Codec/inc/sipviaheader.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004-2009 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:
       
    15 * Name          : sipviaheader.h
       
    16 * Part of       : SIP Codec
       
    17 * Version       : SIP/4.0 
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 
       
    29 #ifndef CSIPVIAHEADER_H
       
    30 #define CSIPVIAHEADER_H
       
    31 
       
    32 //  INCLUDES
       
    33 #include "sipparameterheaderbase.h"
       
    34 #include "_sipcodecdefs.h"
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CSIPViaHeaderParams;
       
    38 class CSIPHostPort;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42 * Class for a SIP Via-header.
       
    43 *
       
    44 * @lib sipcodec.lib
       
    45 */
       
    46 class CSIPViaHeader : public CSIPParameterHeaderBase
       
    47 	{
       
    48 	public:	// Constructors and destructor
       
    49 
       
    50 		/**
       
    51 		* Constructs a CSIPViaHeader from textual representation 
       
    52 		* of the header's value part.
       
    53 		* @param aValue a value part of a "Via"-header
       
    54 		* @return an array containing 1..n instances of CSIPViaHeader
       
    55 		*/
       
    56 		IMPORT_C static RPointerArray<CSIPViaHeader> DecodeL(const TDesC8& aValue);
       
    57 
       
    58 		/**
       
    59 		* Creates a CSIPViaHeader instance with default sent-protocol "SIP/2.0"
       
    60 		* @param aTransport a transport to set e.g. "UDP"
       
    61 		* @param aSentByHostPort the ownership is transferred, @see CSIPHostPort
       
    62 		* @return a new instance of CSIPViaHeader
       
    63 		*/
       
    64 		IMPORT_C static CSIPViaHeader* NewL(RStringF aTransport,
       
    65 		                                    CSIPHostPort* aSentByHostPort);
       
    66 
       
    67 		/**
       
    68 		* Creates a CSIPViaHeader instance with default sent-protocol "SIP/2.0"
       
    69 		* and pushes the created object to CleanupStack.
       
    70 		* @param aTransport a transport to set e.g. "UDP"
       
    71 		* @param aSentByHostPort the ownership is transferred, @see CSIPHostPort
       
    72 		* @return a new instance of CSIPViaHeader
       
    73 		*/
       
    74 		IMPORT_C static CSIPViaHeader* NewLC(RStringF aTransport,
       
    75 		                                     CSIPHostPort* aSentByHostPort);
       
    76 
       
    77 		/**
       
    78 		* Destructor
       
    79 		*/
       
    80 		IMPORT_C ~CSIPViaHeader();
       
    81 
       
    82 
       
    83 	public: // New functions
       
    84 
       
    85 		/**
       
    86 		* Compares this instance to another "Via" header object
       
    87 		* @param aSIPViaHeader a header to compare to
       
    88 		* @return ETrue if "Via" headers are similar
       
    89 		*/
       
    90 		IMPORT_C TBool operator==(const CSIPViaHeader& aSIPViaHeader);
       
    91 
       
    92 		/**
       
    93 		* Gets the transport parameter from the "Via" header
       
    94 		* @returns a transport parameter
       
    95 		*/
       
    96 		IMPORT_C RStringF Transport() const;
       
    97 
       
    98 		/**
       
    99 		* Sets the transport parameter in the "Via" header
       
   100 		* @param aTransport a transport-parameter
       
   101 		*/
       
   102 		IMPORT_C void SetTransportL(RStringF aTransport);
       
   103 
       
   104 		/**
       
   105 		* Gets the sent-by hostport from the "Via" header
       
   106 		* @returns a sent-by hostport @see CSIPHostPort
       
   107 		*/
       
   108 		IMPORT_C CSIPHostPort& SentByHostPort();
       
   109 
       
   110 		/**
       
   111 		* Gets the protocol-name from the "Via" header e.g. "SIP"
       
   112 		* @returns protocol-name
       
   113 		*/
       
   114 		IMPORT_C RStringF SentProtocolName() const;
       
   115 
       
   116 		/**
       
   117 		* Gets the protocol-version from the "Via" header e.g. "2.0"
       
   118 		* @returns protocol-version
       
   119 		*/
       
   120 		IMPORT_C RStringF SentProtocolVersion() const;
       
   121 
       
   122 		/**
       
   123 		* Sets the protocol-version in the "Via" header
       
   124 		* @param aVersion protocol version e.g. "2.0"
       
   125 		*/
       
   126 		IMPORT_C void SetSentProtocolVersionL(RStringF aVersion);
       
   127 
       
   128 		/**
       
   129 		* Gets the value of the "ttl" parameter
       
   130 		* @return the value of the "ttl" parameter or 
       
   131 		*         KErrNotFound if the ttl parameter is not present.
       
   132 		*/	
       
   133 		IMPORT_C TInt TtlParam() const;
       
   134 
       
   135 		/**
       
   136 		* Sets the value of the "ttl" parameter
       
   137 		* @pre aValue >= 0
       
   138 		* @param aValue the value of the "ttl" parameter
       
   139 		*/	
       
   140 		IMPORT_C void SetTtlParamL(TInt aValue);
       
   141 
       
   142 
       
   143 	public: // From CSIPHeaderBase
       
   144 
       
   145 		/**
       
   146 		* From CSIPHeaderBase CloneL
       
   147 		*/
       
   148 		IMPORT_C CSIPHeaderBase* CloneL() const;
       
   149 		
       
   150 		/**
       
   151 		* From CSIPHeaderBase Name
       
   152 		*/		
       
   153 		IMPORT_C RStringF Name() const;
       
   154 
       
   155 		/**
       
   156 		* From CSIPHeaderBase ExternalizeSupported
       
   157 		*/
       
   158 		IMPORT_C TBool ExternalizeSupported() const;
       
   159 
       
   160 
       
   161 	public: // New functions, for internal use
       
   162 
       
   163 		static RPointerArray<CSIPHeaderBase> BaseDecodeL(const TDesC8& aValue);
       
   164 
       
   165 	public: // From CSIPHeaderBase, for internal use
       
   166 	
       
   167 		TBool MoreThanOneAllowed() const;	
       
   168 		TBool HasCompactName() const;
       
   169 		RStringF CompactName() const;
       
   170 		TPreferredPlace PreferredPlaceInMessage() const;
       
   171 
       
   172 	private: // From CSIPParameterHeaderBase
       
   173 
       
   174 		HBufC8* ToTextMandatoryPartLC() const;
       
   175 		void ParseMandatoryPartL(const TDesC8& aMandatoryPart);
       
   176 		const CSIPParamContainerBase& Params() const;
       
   177 		CSIPParamContainerBase& Params();
       
   178 
       
   179 	private: // Constructors
       
   180 
       
   181 		CSIPViaHeader ();
       
   182 		void ConstructL();
       
   183 		void ConstructL(RStringF aTransport, CSIPHostPort* aSentByHostPort);
       
   184 		void ConstructL(const CSIPViaHeader& aViaHeader);
       
   185 
       
   186 	private: // New functions 
       
   187 
       
   188 		void ParseSentProtocolL(const TDesC8& aValue, TInt& aLength);
       
   189 		void SetTransportL(const TDesC8& aTransport);
       
   190 		void SetSentProtocolVersionL(const TDesC8& aVersion);
       
   191 		void SetSentProtocolNameL(const TDesC8& aName);	
       
   192 
       
   193 	private: // Data
       
   194 
       
   195 		RStringF iSentProtocolName;
       
   196 		RStringF iSentProtocolVersion;
       
   197 		RStringF iTransport;
       
   198 		CSIPHostPort* iSentByHostPort;
       
   199 		CSIPViaHeaderParams* iParams;
       
   200 
       
   201 	private: // For testing purposes
       
   202 	
       
   203 		UNIT_TEST(CSIPViaHeaderTest)
       
   204 	};
       
   205 
       
   206 #endif // CSIPVIAHEADER_H
       
   207 
       
   208 // End of File