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 "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 : 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>
32 // FORWARD DECLARATIONS
34 class CSIPContentTypeHeader;
38 class CSIPExtensionHeader;
46 * Class for creation and manipulation optional elements in a SIP message.
48 * Class provides functions for setting and getting optional elements in a
49 * SIP message. Optional elements include user SIP message headers,
50 * content and content type.
51 * Following headers are not considered to be user SIP message headers and
52 * cannot be set or retrieved using functions of this class:
53 * "Authentication-Info", "Call-Id", "CSeq", "From"
54 * "Max-Forwards", "Min-Expires", "Record-Route",
55 * "Security-Verify", "Service-Route", "To", "Via", "Security-Server" and
56 * "Proxy-Authorization".
60 class CSIPMessageElements : public CBase
62 public: // Constructors and destructor
64 * Two-phased constructor.
66 IMPORT_C static CSIPMessageElements* NewL();
69 * Two-phased constructor.
71 IMPORT_C static CSIPMessageElements* NewLC();
76 IMPORT_C ~CSIPMessageElements();
78 public: //new functions
80 * Sets an array of user headers i.e. headers that user is allowed
81 * manipulate to a SIP message. An empty array resets the user headers.
82 * Note that the Content-Type header must be set using SetContentL.
84 * @param aHeaders an array of SIP headers.
85 * The ownership of objects in the array is transferred.
87 IMPORT_C void SetUserHeadersL(RPointerArray<CSIPHeaderBase>& aHeaders);
90 * Gets all user SIP headers this class contains
91 * @return SIP headers. Ownership is not transferred.
93 IMPORT_C const RPointerArray<CSIPHeaderBase>& UserHeaders() const;
96 * Sets the SIP message content and its type.
97 * A zero length content can be set by providing a pointer
98 * to a zero length HBufC8 instance (the ownership is transferred).
99 * @pre aContent != 0 && aContentType != 0
100 * @param aContent the content of a SIP message,
101 * the ownership is transferred
102 * @param aContentType the SIP message content type,
103 * the ownership is transferred
104 * @leave KErrArgument if aContent == 0 or
107 IMPORT_C void SetContentL(HBufC8* aContent,
108 CSIPContentTypeHeader* aContentType);
111 * Gets the SIP message content
112 * @return SIP message content. If content does not exist, an empty
113 * descriptor is returned.
115 IMPORT_C const TDesC8& Content() const;
118 * Gets the content type
119 * @return Content-Type-header or a 0-pointer if not present; the ownership
120 * is not transferred.
122 IMPORT_C const CSIPContentTypeHeader* ContentType() const;
125 * Removes the SIP message content and destroys
126 * Content-Type header as well.
127 * @return SIP message content; the ownership is transferred.
129 IMPORT_C HBufC8* ExtractContent();
131 public: // New functions, for internal use
133 static CSIPMessageElements* InternalizeL(RReadStream& aReadStream);
134 void ExternalizeL(RWriteStream& aWriteStream) const;
135 TInt UserHeaderCount(RStringF aName) const;
136 const RPointerArray<CSIPHeaderBase> UserHeadersL(RStringF aName) const;
137 TInt RemoveHeaders(RStringF aName);
138 void DetachUserHeader(CSIPHeaderBase* aHeader);
139 void AddHeaderL(CSIPHeaderBase* aHeader);
140 void SetToL(CSIPToHeader* aTo);
141 const CSIPToHeader* To() const;
142 void SetFromL (CSIPFromHeader* aFrom);
143 const CSIPFromHeader* From() const;
144 const CSIPCSeqHeader* CSeq() const;
145 void SetContent(HBufC8* aContent);
146 void DetachContent();
150 CSIPMessageElements();
152 void DoInternalizeL(RReadStream& aReadStream);
153 void CheckUserHeaderL(const CSIPHeaderBase* aHeader) const;
154 void ExternalizeUserHeadersL(RWriteStream& aWriteStream) const;
155 void ExternalizeL(const CSIPExtensionHeader* aHeader,
156 RWriteStream& aWriteStream) const;
160 RPointerArray<CSIPHeaderBase> iUserHeaders;
162 CSIPFromHeader* iFromHeader;
163 CSIPToHeader* iToHeader;
164 CSIPCSeqHeader* iCSeqHeader;
165 CSIPContentTypeHeader* iContentTypeHeader;
166 TBool iHeaderLookupOpen;
168 private: // For testing purposes
170 friend class CSIPMessageElementsTest;