2 * Copyright (c) 2005-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 : sipmessageelements.h
16 * Part of : SIP Client
17 * Interface : SDK API, SIP API
24 #ifndef CSIPMESSAGEELEMENTS_H
25 #define CSIPMESSAGEELEMENTS_H
30 #include <stringpool.h>
31 #include "_sipcodecdefs.h"
33 // FORWARD DECLARATIONS
35 class CSIPContentTypeHeader;
39 class CSIPExtensionHeader;
47 * Class for creation and manipulation optional elements in a SIP message.
49 * Class provides functions for setting and getting optional elements in a
50 * SIP message. Optional elements include user SIP message headers,
51 * content and content type.
52 * Following headers are not considered to be user SIP message headers and
53 * cannot be set or retrieved using functions of this class:
54 * "Authentication-Info", "Call-Id", "CSeq", "From"
55 * "Max-Forwards", "Min-Expires", "Record-Route",
56 * "Security-Verify", "Service-Route", "To", "Via", "Security-Server" and
57 * "Proxy-Authorization".
61 class CSIPMessageElements : public CBase
63 public: // Constructors and destructor
65 * Two-phased constructor.
67 IMPORT_C static CSIPMessageElements* NewL();
70 * Two-phased constructor.
72 IMPORT_C static CSIPMessageElements* NewLC();
77 IMPORT_C ~CSIPMessageElements();
79 public: //new functions
81 * Sets an array of user headers i.e. headers that user is allowed
82 * manipulate to a SIP message. An empty array resets the user headers.
83 * Note that the Content-Type header must be set using SetContentL.
85 * @param aHeaders an array of SIP headers.
86 * The ownership of objects in the array is transferred.
88 IMPORT_C void SetUserHeadersL(RPointerArray<CSIPHeaderBase>& aHeaders);
91 * Gets all user SIP headers this class contains
92 * @return SIP headers. Ownership is not transferred.
94 IMPORT_C const RPointerArray<CSIPHeaderBase>& UserHeaders() const;
97 * Sets the SIP message content and its type.
98 * A zero length content can be set by providing a pointer
99 * to a zero length HBufC8 instance (the ownership is transferred).
100 * @pre aContent != 0 && aContentType != 0
101 * @param aContent the content of a SIP message,
102 * the ownership is transferred
103 * @param aContentType the SIP message content type,
104 * the ownership is transferred
105 * @leave KErrArgument if aContent == 0 or
108 IMPORT_C void SetContentL(HBufC8* aContent,
109 CSIPContentTypeHeader* aContentType);
112 * Gets the SIP message content
113 * @return SIP message content. If content does not exist, an empty
114 * descriptor is returned.
116 IMPORT_C const TDesC8& Content() const;
119 * Gets the content type
120 * @return Content-Type-header or a 0-pointer if not present; the ownership
121 * is not transferred.
123 IMPORT_C const CSIPContentTypeHeader* ContentType() const;
126 * Removes the SIP message content and destroys
127 * Content-Type header as well.
128 * @return SIP message content; the ownership is transferred.
130 IMPORT_C HBufC8* ExtractContent();
132 public: // New functions, for internal use
134 static CSIPMessageElements* InternalizeL(RReadStream& aReadStream);
135 void ExternalizeL(RWriteStream& aWriteStream) const;
136 TInt UserHeaderCount(RStringF aName) const;
137 const RPointerArray<CSIPHeaderBase> UserHeadersL(RStringF aName) const;
138 TInt RemoveHeaders(RStringF aName);
139 void DetachUserHeader(CSIPHeaderBase* aHeader);
140 void AddHeaderL(CSIPHeaderBase* aHeader);
141 void SetToL(CSIPToHeader* aTo);
142 const CSIPToHeader* To() const;
143 void SetFromL (CSIPFromHeader* aFrom);
144 const CSIPFromHeader* From() const;
145 const CSIPCSeqHeader* CSeq() const;
146 void SetContent(HBufC8* aContent);
147 void DetachContent();
151 CSIPMessageElements();
153 void DoInternalizeL(RReadStream& aReadStream);
154 void CheckUserHeaderL(const CSIPHeaderBase* aHeader) const;
155 void ExternalizeUserHeadersL(RWriteStream& aWriteStream) const;
156 void ExternalizeL(const CSIPExtensionHeader* aHeader,
157 RWriteStream& aWriteStream) const;
161 RPointerArray<CSIPHeaderBase> iUserHeaders;
163 CSIPFromHeader* iFromHeader;
164 CSIPToHeader* iToHeader;
165 CSIPCSeqHeader* iCSeqHeader;
166 CSIPContentTypeHeader* iContentTypeHeader;
167 TBool iHeaderLookupOpen;
169 private: // For testing purposes
171 UNIT_TEST(CSIPMessageElementsTest)