|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Name : sipmessageelements.h |
|
16 * Part of : SIP Client |
|
17 * Interface : SDK API, SIP API |
|
18 * Version : 1.0 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef CSIPMESSAGEELEMENTS_H |
|
25 #define CSIPMESSAGEELEMENTS_H |
|
26 |
|
27 // INCLUDES |
|
28 #include <e32base.h> |
|
29 #include <s32strm.h> |
|
30 #include <stringpool.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CSIPHeaderBase; |
|
34 class CSIPContentTypeHeader; |
|
35 class CSIPFromHeader; |
|
36 class CSIPToHeader; |
|
37 class CSIPCSeqHeader; |
|
38 class CSIPExtensionHeader; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * @publishedAll |
|
44 * @released |
|
45 * |
|
46 * Class for creation and manipulation optional elements in a SIP message. |
|
47 * |
|
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". |
|
57 * |
|
58 * @lib sipclient.lib |
|
59 */ |
|
60 class CSIPMessageElements : public CBase |
|
61 { |
|
62 public: // Constructors and destructor |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 */ |
|
66 IMPORT_C static CSIPMessageElements* NewL(); |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 */ |
|
71 IMPORT_C static CSIPMessageElements* NewLC(); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 IMPORT_C ~CSIPMessageElements(); |
|
77 |
|
78 public: //new functions |
|
79 /** |
|
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. |
|
83 * |
|
84 * @param aHeaders an array of SIP headers. |
|
85 * The ownership of objects in the array is transferred. |
|
86 */ |
|
87 IMPORT_C void SetUserHeadersL(RPointerArray<CSIPHeaderBase>& aHeaders); |
|
88 |
|
89 /** |
|
90 * Gets all user SIP headers this class contains |
|
91 * @return SIP headers. Ownership is not transferred. |
|
92 */ |
|
93 IMPORT_C const RPointerArray<CSIPHeaderBase>& UserHeaders() const; |
|
94 |
|
95 /** |
|
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 |
|
105 * aContentType == 0 |
|
106 */ |
|
107 IMPORT_C void SetContentL(HBufC8* aContent, |
|
108 CSIPContentTypeHeader* aContentType); |
|
109 |
|
110 /** |
|
111 * Gets the SIP message content |
|
112 * @return SIP message content. If content does not exist, an empty |
|
113 * descriptor is returned. |
|
114 */ |
|
115 IMPORT_C const TDesC8& Content() const; |
|
116 |
|
117 /** |
|
118 * Gets the content type |
|
119 * @return Content-Type-header or a 0-pointer if not present; the ownership |
|
120 * is not transferred. |
|
121 */ |
|
122 IMPORT_C const CSIPContentTypeHeader* ContentType() const; |
|
123 |
|
124 /* |
|
125 * Removes the SIP message content and destroys |
|
126 * Content-Type header as well. |
|
127 * @return SIP message content; the ownership is transferred. |
|
128 */ |
|
129 IMPORT_C HBufC8* ExtractContent(); |
|
130 |
|
131 public: // New functions, for internal use |
|
132 |
|
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(); |
|
147 |
|
148 private: |
|
149 |
|
150 CSIPMessageElements(); |
|
151 void ConstructL(); |
|
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; |
|
157 |
|
158 private: // Data |
|
159 |
|
160 RPointerArray<CSIPHeaderBase> iUserHeaders; |
|
161 HBufC8* iContent; |
|
162 CSIPFromHeader* iFromHeader; |
|
163 CSIPToHeader* iToHeader; |
|
164 CSIPCSeqHeader* iCSeqHeader; |
|
165 CSIPContentTypeHeader* iContentTypeHeader; |
|
166 TBool iHeaderLookupOpen; |
|
167 |
|
168 private: // For testing purposes |
|
169 #ifdef CPPUNIt_TEST |
|
170 friend class CSIPMessageElementsTest; |
|
171 #endif |
|
172 }; |
|
173 |
|
174 #endif |