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 : sipcontenttypeheader.h
17 * Interface : SDK API, SIP Codec API
25 #ifndef CSIPCONTENTTYPEHEADER_H
26 #define CSIPCONTENTTYPEHEADER_H
29 #include "sipparameterheaderbase.h"
31 // FORWARD DECLARATIONS
32 class CSIPContentTypeHeaderParams;
39 * Class provides functions for setting and getting media types and
40 * parameters in SIP "Content-Type" header.
44 class CSIPContentTypeHeader : public CSIPParameterHeaderBase
46 public: // Constructors and destructor
49 * Constructs a CSIPContentTypeHeader from textual representation
50 * of the header's value part.
51 * @param aValue a value part of a "Content-Type"-header
52 * @return a new instance of CSIPContentTypeHeader
54 IMPORT_C static CSIPContentTypeHeader* DecodeL(const TDesC8& aValue);
57 * Creates a new instance of CSIPContentTypeHeader
58 * @param aMediaType a media type to set. For example "application"
59 * @param aMediaSubtype a media subtype to set. For example "sdp"
60 * @return a new instance of CSIPContentTypeHeader
62 IMPORT_C static CSIPContentTypeHeader*
63 NewL(const TDesC8& aMediaType, const TDesC8& aMediaSubtype);
66 * Creates a new instance of CSIPContentTypeHeader
67 * and puts it onto the cleanup stack
68 * @param aMediaType a media type to set. For example "application"
69 * @param aMediaSubtype a media subtype to set. For example "sdp"
70 * @return a new instance of CSIPContentTypeHeader
72 IMPORT_C static CSIPContentTypeHeader*
73 NewLC(const TDesC8& aMediaType, const TDesC8& aMediaSubtype);
76 * Destructor, deletes the resources of CSIPContentTypeHeader.
78 IMPORT_C ~CSIPContentTypeHeader();
80 public: // New functions
83 * Gets the media type from the "Content-Type" header
84 * @return a media type
86 IMPORT_C const TDesC8& MediaType() const;
89 * Sets the media type in the "Content-Type" header
90 * @param aMediaType a media type
92 IMPORT_C void SetMediaTypeL(const TDesC8& aMediaType);
95 * Gets the media subtype from the "Content-Type" header
96 * @return a media subtype
98 IMPORT_C const TDesC8& MediaSubtype() const;
101 * Sets the media subtype in the "Content-Type" header
102 * @param aMediaSubtype a media subtype
104 IMPORT_C void SetMediaSubtypeL(const TDesC8& aMediaSubtype);
107 * Constructs an instance of a CSIPContentTypeHeader from a RReadStream
108 * @param aReadStream a stream containing the value of the
109 * externalized header object (header name not included).
110 * @return an instance of a CSIPContentTypeHeader
113 IMPORT_C static CSIPHeaderBase*
114 InternalizeValueL(RReadStream& aReadStream);
117 public: // From CSIPHeaderBase
120 * From CSIPHeaderBase CloneL
122 IMPORT_C CSIPHeaderBase* CloneL() const;
125 * From CSIPHeaderBase Name
127 IMPORT_C RStringF Name() const;
130 public: // From CSIPHeaderBase, for internal use
135 TBool HasCompactName() const;
140 RStringF CompactName() const;
145 TPreferredPlace PreferredPlaceInMessage() const;
147 public: // New functions, for internal use
149 static RPointerArray<CSIPHeaderBase> BaseDecodeL(const TDesC8& aValue);
151 private: // From CSIPHeaderBase
153 void ExternalizeValueL(RWriteStream& aWriteStream) const;
155 private: // CSIPParameterHeaderBase
157 HBufC8* ToTextMandatoryPartLC() const;
158 void ParseMandatoryPartL(const TDesC8& aMandatoryPart);
159 const CSIPParamContainerBase& Params() const;
160 CSIPParamContainerBase& Params();
162 private: // Constructors
164 CSIPContentTypeHeader();
166 void ConstructL(const TDesC8& aMediaType, const TDesC8& aMediaSubtype);
167 void ConstructL(const CSIPContentTypeHeader& aContentTypeHeader);
169 private: // New functions
171 void DoInternalizeValueL(RReadStream& aReadStream);
176 HBufC8* iMediaSubtype;
177 CSIPContentTypeHeaderParams* iParams;
179 private: // For testing purposes
181 friend class CSIPContentTypeHeaderTest;
185 #endif // CSIPCONTENTTYPEHEADER_H