2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Name : sipacceptheader.h
17 * Interface : SDK API, SIP Codec API
25 #ifndef CSIPACCEPTHEADER_H
26 #define CSIPACCEPTHEADER_H
29 #include "sipparameterheaderbase.h"
30 #include "_sipcodecdefs.h"
32 // FORWARD DECLARATIONS
33 class CSIPAcceptHeaderParams;
41 * Class provides functions for setting and getting media types and
42 * parameters in SIP "Accept" header.
46 class CSIPAcceptHeader : public CSIPParameterHeaderBase
48 public: // Constructors and destructor
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.
58 IMPORT_C static RPointerArray<CSIPAcceptHeader>
59 DecodeL(const TDesC8& aValue);
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
67 IMPORT_C static CSIPAcceptHeader* NewL(const TDesC8& aMediaType,
68 const TDesC8& aMediaSubtype);
71 * Creates a new instance of CSIPAcceptHeader and puts it into
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
77 IMPORT_C static CSIPAcceptHeader* NewLC(const TDesC8& aMediaType,
78 const TDesC8& aMediaSubtype);
81 * Destructor, deletes the resources of CSIPAcceptHeader.
83 IMPORT_C ~CSIPAcceptHeader();
86 public: // New functions
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.
93 IMPORT_C TBool IsEmpty() const;
96 * Gets the media type from the "Accept" header
97 * @return a media type
99 IMPORT_C const TDesC8& MediaType() const;
102 * Sets the media type in the "Accept" header
103 * @pre IsEmpty() == EFalse
104 * @param aMediaType a media type
106 IMPORT_C void SetMediaTypeL(const TDesC8& aMediaType);
109 * Gets the media subtype from the "Accept" header
110 * @return a media subtype
112 IMPORT_C const TDesC8& MediaSubtype() const;
114 * Sets the media subtype in the "Accept" header
115 * @pre IsEmpty() == EFalse
116 * @param aMediaSubtype a media subtype
118 IMPORT_C void SetMediaSubtypeL(const TDesC8& aMediaSubtype);
121 * Gets the value of "q"-parameter
122 * @return the "q"-parameter value
124 IMPORT_C TReal QParameter() const;
127 * Sets the "q"-parameter value
128 * @param aQValue a "q"-parameter value to set
130 IMPORT_C void SetQParameterL(TReal aQValue);
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
138 IMPORT_C static CSIPHeaderBase*
139 InternalizeValueL(RReadStream& aReadStream);
142 public: // From CSIPHeaderBase
145 * From CSIPHeaderBase CloneL
147 IMPORT_C CSIPHeaderBase* CloneL() const;
150 * From CSIPHeaderBase Name
152 IMPORT_C RStringF Name() const;
155 public: // From CSIPHeaderBase, for internal use
160 TBool MoreThanOneAllowed() const;
165 TPreferredPlace PreferredPlaceInMessage() const;
167 public: // New functions, for internal use
169 static RPointerArray<CSIPHeaderBase> BaseDecodeL(const TDesC8& aValue);
171 private: // From CSIPHeaderBase
173 void ExternalizeValueL(RWriteStream& aWriteStream) const;
175 private: // From CSIPParameterHeaderBase
177 HBufC8* ToTextMandatoryPartLC() const;
178 void ParseMandatoryPartL(const TDesC8& aMandatoryPart);
179 const CSIPParamContainerBase& Params() const;
180 CSIPParamContainerBase& Params();
182 private: // Constructors
184 CSIPAcceptHeader(TBool aEmpty=EFalse);
186 void ConstructL(const TDesC8& aMediaType, const TDesC8& aMediaSubtype);
187 void ConstructL(const CSIPAcceptHeader& aAcceptHeader);
189 private: // New functions
191 void DoInternalizeValueL(RReadStream& aReadStream);
197 HBufC8* iMediaSubtype;
198 CSIPAcceptHeaderParams* iParams;
200 private: // For testing purposes
202 UNIT_TEST(CSIPAcceptHeaderTest)
205 #endif // CSIPACCEPTHEADER_H