realtimenetprots/sipfw/SIP/Codec/api/sipacceptheader.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        : sipacceptheader.h
       
    16 * Part of     : SIP Codec
       
    17 * Interface   : SDK API, SIP Codec API
       
    18 * Version     : SIP/4.0 
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef CSIPACCEPTHEADER_H
       
    26 #define CSIPACCEPTHEADER_H
       
    27 
       
    28 //  INCLUDES
       
    29 #include "sipparameterheaderbase.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CSIPAcceptHeaderParams;
       
    33 
       
    34 
       
    35 // CLASS DECLARATION
       
    36 /**
       
    37 * @publishedAll
       
    38 * @released
       
    39 *
       
    40 * Class provides functions for setting and getting media types and
       
    41 * parameters in SIP "Accept" header.
       
    42 *
       
    43 *  @lib sipcodec.lib
       
    44 */
       
    45 class CSIPAcceptHeader : public CSIPParameterHeaderBase
       
    46 	{
       
    47 	public:	// Constructors and destructor
       
    48 
       
    49 		/**
       
    50 		* Constructs a CSIPAcceptHeader from textual representation 
       
    51 		* of the header's value part.
       
    52 		* An empty Accept-header can be created using this function
       
    53 		* by passing a KNullDesC8 as a parameter.
       
    54 		* @param aValue a value part of a "Accept"-header
       
    55 		* @return an array containing one to many instances of CSIPAcceptHeader.
       
    56 		*/
       
    57 		IMPORT_C static RPointerArray<CSIPAcceptHeader> 
       
    58 			DecodeL(const TDesC8& aValue);
       
    59 
       
    60 		/**
       
    61 		* Creates a new instance of CSIPAcceptHeader
       
    62 		* @param aMediaType a media type to set. For example "application"
       
    63 		* @param aMediaSubtype a media subtype to set. For example "sdp"
       
    64 		* @return a new instance of CSIPAcceptHeader
       
    65 		*/
       
    66 		IMPORT_C static CSIPAcceptHeader* NewL(const TDesC8& aMediaType,
       
    67 		                                       const TDesC8& aMediaSubtype);
       
    68 
       
    69 		/**
       
    70 		* Creates a new instance of CSIPAcceptHeader and puts it into 
       
    71 		* the cleanup stack
       
    72 		* @param aMediaType a media type to set. For example "application"
       
    73 		* @param aMediaSubtype a media subtype to set. For example "sdp"
       
    74 		* @return a new instance of CSIPAcceptHeader
       
    75 		*/
       
    76 		IMPORT_C static CSIPAcceptHeader* NewLC(const TDesC8& aMediaType,
       
    77 		                                        const TDesC8& aMediaSubtype);
       
    78 
       
    79 		/**
       
    80 		* Destructor, deletes the resources of CSIPAcceptHeader.
       
    81 		*/
       
    82 		IMPORT_C ~CSIPAcceptHeader();
       
    83 
       
    84 
       
    85 	public: // New functions
       
    86 
       
    87 		/**
       
    88 		* Check if the header is empty. If so, 
       
    89 		* the other getters will not return a meaningful value.
       
    90 		* @return ETrue if empty, EFalse otherwise.
       
    91 		*/
       
    92 		IMPORT_C TBool IsEmpty() const;
       
    93     
       
    94 		/**
       
    95 		* Gets the media type from the "Accept" header
       
    96 		* @return a media type
       
    97 		*/
       
    98 		IMPORT_C const TDesC8& MediaType() const;
       
    99 
       
   100 		/**
       
   101 		* Sets the media type in the "Accept" header
       
   102 		* @pre IsEmpty() == EFalse
       
   103 		* @param aMediaType a media type
       
   104 		*/
       
   105 		IMPORT_C void SetMediaTypeL(const TDesC8& aMediaType);
       
   106 
       
   107 		/**
       
   108 		* Gets the media subtype from the "Accept" header
       
   109 		* @return a media subtype
       
   110 		*/
       
   111 		IMPORT_C const TDesC8& MediaSubtype() const;
       
   112 		/**
       
   113 		* Sets the media subtype in the "Accept" header
       
   114 		* @pre IsEmpty() == EFalse
       
   115 		* @param aMediaSubtype a media subtype
       
   116 		*/
       
   117 		IMPORT_C void SetMediaSubtypeL(const TDesC8& aMediaSubtype);
       
   118 
       
   119 		/**
       
   120 		* Gets the value of "q"-parameter
       
   121 		* @return the "q"-parameter value
       
   122 		*/
       
   123 		IMPORT_C TReal QParameter() const;
       
   124 
       
   125 		/**
       
   126 		* Sets the "q"-parameter value
       
   127 		* @param aQValue a "q"-parameter value to set
       
   128 		*/
       
   129 		IMPORT_C void SetQParameterL(TReal aQValue);
       
   130 
       
   131 		/**
       
   132 		* Constructs an instance of a CSIPAcceptHeader from a RReadStream
       
   133 		* @param aReadStream a stream containing the value of the
       
   134 		*        externalized header object (header name not included).
       
   135 		* @return An instance of a CSIPAcceptHeader
       
   136 		*/
       
   137 		IMPORT_C static CSIPHeaderBase* 
       
   138 			InternalizeValueL(RReadStream& aReadStream);
       
   139 
       
   140 
       
   141 	public: // From CSIPHeaderBase
       
   142 
       
   143 		/**
       
   144 		* From CSIPHeaderBase CloneL
       
   145 		*/
       
   146 		IMPORT_C CSIPHeaderBase* CloneL() const;
       
   147 
       
   148 		/**
       
   149 		* From CSIPHeaderBase Name
       
   150 		*/
       
   151 		IMPORT_C RStringF Name() const;
       
   152 
       
   153 
       
   154 	public: // From CSIPHeaderBase, for internal use
       
   155 
       
   156         /**
       
   157         * @internalComponent
       
   158         */
       
   159 		TBool MoreThanOneAllowed() const;
       
   160 		
       
   161         /**
       
   162         * @internalComponent
       
   163         */		
       
   164 		TPreferredPlace PreferredPlaceInMessage() const;
       
   165 
       
   166 	public: // New functions, for internal use
       
   167 
       
   168 		static RPointerArray<CSIPHeaderBase> BaseDecodeL(const TDesC8& aValue);
       
   169 
       
   170 	private: // From CSIPHeaderBase
       
   171 
       
   172 		void ExternalizeValueL(RWriteStream& aWriteStream) const;
       
   173 
       
   174 	private: // From CSIPParameterHeaderBase
       
   175 
       
   176 		HBufC8* ToTextMandatoryPartLC() const;
       
   177 		void ParseMandatoryPartL(const TDesC8& aMandatoryPart);
       
   178 		const CSIPParamContainerBase& Params() const;
       
   179 		CSIPParamContainerBase& Params();
       
   180 
       
   181 	private: // Constructors
       
   182 
       
   183 		CSIPAcceptHeader(TBool aEmpty=EFalse);
       
   184 		void ConstructL();
       
   185 		void ConstructL(const TDesC8& aMediaType, const TDesC8& aMediaSubtype);
       
   186 		void ConstructL(const CSIPAcceptHeader& aAcceptHeader);
       
   187 
       
   188 	private: // New functions
       
   189 
       
   190 		void DoInternalizeValueL(RReadStream& aReadStream);
       
   191 
       
   192 	private: // Data
       
   193 
       
   194 		TBool iEmpty;
       
   195 		HBufC8* iMediaType;
       
   196 		HBufC8* iMediaSubtype;
       
   197 		CSIPAcceptHeaderParams* iParams;
       
   198 
       
   199 	private: // For testing purposes
       
   200 #ifdef CPPUNIT_TEST	
       
   201 		friend class CSIPAcceptHeaderTest;
       
   202 #endif
       
   203 	};
       
   204 
       
   205 #endif // CSIPACCEPTHEADER_H
       
   206 
       
   207 // End of File