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