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 "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".
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"
31 // FORWARD DECLARATIONS
32 class CSIPAcceptHeaderParams;
40 * Class provides functions for setting and getting media types and
41 * parameters in SIP "Accept" header.
45 class CSIPAcceptHeader : public CSIPParameterHeaderBase
47 public: // Constructors and destructor
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.
57 IMPORT_C static RPointerArray<CSIPAcceptHeader>
58 DecodeL(const TDesC8& aValue);
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
66 IMPORT_C static CSIPAcceptHeader* NewL(const TDesC8& aMediaType,
67 const TDesC8& aMediaSubtype);
70 * Creates a new instance of CSIPAcceptHeader and puts it into
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
76 IMPORT_C static CSIPAcceptHeader* NewLC(const TDesC8& aMediaType,
77 const TDesC8& aMediaSubtype);
80 * Destructor, deletes the resources of CSIPAcceptHeader.
82 IMPORT_C ~CSIPAcceptHeader();
85 public: // New functions
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.
92 IMPORT_C TBool IsEmpty() const;
95 * Gets the media type from the "Accept" header
96 * @return a media type
98 IMPORT_C const TDesC8& MediaType() const;
101 * Sets the media type in the "Accept" header
102 * @pre IsEmpty() == EFalse
103 * @param aMediaType a media type
105 IMPORT_C void SetMediaTypeL(const TDesC8& aMediaType);
108 * Gets the media subtype from the "Accept" header
109 * @return a media subtype
111 IMPORT_C const TDesC8& MediaSubtype() const;
113 * Sets the media subtype in the "Accept" header
114 * @pre IsEmpty() == EFalse
115 * @param aMediaSubtype a media subtype
117 IMPORT_C void SetMediaSubtypeL(const TDesC8& aMediaSubtype);
120 * Gets the value of "q"-parameter
121 * @return the "q"-parameter value
123 IMPORT_C TReal QParameter() const;
126 * Sets the "q"-parameter value
127 * @param aQValue a "q"-parameter value to set
129 IMPORT_C void SetQParameterL(TReal aQValue);
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
137 IMPORT_C static CSIPHeaderBase*
138 InternalizeValueL(RReadStream& aReadStream);
141 public: // From CSIPHeaderBase
144 * From CSIPHeaderBase CloneL
146 IMPORT_C CSIPHeaderBase* CloneL() const;
149 * From CSIPHeaderBase Name
151 IMPORT_C RStringF Name() const;
154 public: // From CSIPHeaderBase, for internal use
159 TBool MoreThanOneAllowed() const;
164 TPreferredPlace PreferredPlaceInMessage() const;
166 public: // New functions, for internal use
168 static RPointerArray<CSIPHeaderBase> BaseDecodeL(const TDesC8& aValue);
170 private: // From CSIPHeaderBase
172 void ExternalizeValueL(RWriteStream& aWriteStream) const;
174 private: // From CSIPParameterHeaderBase
176 HBufC8* ToTextMandatoryPartLC() const;
177 void ParseMandatoryPartL(const TDesC8& aMandatoryPart);
178 const CSIPParamContainerBase& Params() const;
179 CSIPParamContainerBase& Params();
181 private: // Constructors
183 CSIPAcceptHeader(TBool aEmpty=EFalse);
185 void ConstructL(const TDesC8& aMediaType, const TDesC8& aMediaSubtype);
186 void ConstructL(const CSIPAcceptHeader& aAcceptHeader);
188 private: // New functions
190 void DoInternalizeValueL(RReadStream& aReadStream);
196 HBufC8* iMediaSubtype;
197 CSIPAcceptHeaderParams* iParams;
199 private: // For testing purposes
201 friend class CSIPAcceptHeaderTest;
205 #endif // CSIPACCEPTHEADER_H