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 : sipheaderbase.h
17 * Interface : SDK API, SIP Codec API
25 #ifndef CSIPHEADERBASE_H
26 #define CSIPHEADERBASE_H
31 #include <stringpool.h>
38 * Class provides a generic interface for all the SIP headers.
42 class CSIPHeaderBase : public CBase
44 public: // Constructors and destructors
47 * Destructor, deletes the resources of CSIPHeaderBase.
49 IMPORT_C virtual ~CSIPHeaderBase();
52 public: // New functions
55 * Creates a deep-copy of this CSIPHeaderBase object.
56 * The function has to be implemented in each of the sub-classes.
57 * @return the deep-copied object, the ownership is transferred.
59 IMPORT_C virtual CSIPHeaderBase* CloneL() const = 0;
62 * Gets the full name of the header
63 * The function is implemented in each of the sub-classes.
64 * @return the full name of the header for example "From"
66 IMPORT_C virtual RStringF Name() const = 0;
69 * Encodes the header (name and value) into its textual representation.
70 * @return a textual representation of the complete header,
71 * the ownership is transferred
73 IMPORT_C HBufC8* ToTextL() const;
76 * Encodes the header (name and value) into its textual representation
77 * and pushes it to the CleanupStack.
78 * @return a textual representation of the complete header,
79 * the ownership is transferred
81 IMPORT_C HBufC8* ToTextLC() const;
84 * Encodes the header's value into its textual representation.
85 * @return a textual representation of the header's value,
86 * the ownership is transferred
88 IMPORT_C virtual HBufC8* ToTextValueL() const = 0;
91 * Encodes the header's value into its textual representation
92 * and pushes it to the CleanupStack.
93 * @return a textual representation of the header's value,
94 * the ownership is transferred
96 IMPORT_C HBufC8* ToTextValueLC() const;
99 * Writes the object to a RWriteStream
100 * @param aWriteStream a stream where the object is to be externalized
101 * @param aAddName if ETrue the name of the header is
102 * also written to the stream
104 IMPORT_C void ExternalizeL(RWriteStream& aWriteStream,
105 TBool aAddName=ETrue) const;
108 * Checks, if the header supports serialization.
109 * In practice all the headers part of the API support it.
110 * @return ETrue, if the header supports serialization,
113 IMPORT_C virtual TBool ExternalizeSupported() const;
116 * Can be used when a RPointerArray<CSIPHeaderBase> needs to be pushed
117 * to the CleanupStack for ResetAndDestroy.
118 * @param aArray an array of CSIPHeaderBase pointers,
119 * the ownership of the array is transferred
121 IMPORT_C static void PushLC(RPointerArray<CSIPHeaderBase>* aArray);
124 public: // For internal use
146 virtual TBool EncodeMultipleToOneLine() const;
151 virtual TBool MoreThanOneAllowed() const;
156 virtual TBool IsExtensionHeader() const;
161 virtual TBool HasCompactName() const;
166 virtual RStringF CompactName() const;
171 virtual TPreferredPlace PreferredPlaceInMessage() const = 0;
173 protected: // Constructors
177 protected: // New functions
179 void ExternalizeNameL(RWriteStream& aWriteStream) const;
184 virtual void ExternalizeValueL(RWriteStream& aWriteStream) const;
186 // Needed for cleanup of a RPointerArray<CSIPHeaderBase>:
187 static void ResetAndDestroy(TAny* anArray);
190 #endif // CSIPHEADERBASE_H