|
1 /* |
|
2 * Copyright (c) 2007 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CSIPREQUESTELEMENTS_H |
|
20 #define CSIPREQUESTELEMENTS_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "musunittesting.h" |
|
24 #include <e32base.h> |
|
25 #include <s32strm.h> |
|
26 #include <stringpool.h> |
|
27 #include <uri8.h> |
|
28 #include "_sipcodecdefs.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CSIPMessageElements; |
|
32 class CSIPFromHeader; |
|
33 class CSIPToHeader; |
|
34 class CSIPCSeqHeader; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * @publishedAll |
|
40 * @released |
|
41 * |
|
42 * Class provides functions for creation and manipulation of originator's and |
|
43 * recipient's addresses in a SIP request. It also provide functions for |
|
44 * manipulation of SIP method for unknown SIP requests. |
|
45 * @lib sipclient.lib |
|
46 */ |
|
47 class CSIPRequestElements : public CBase |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * If the URI is SIP URI, no SIP URI headers are allowed. |
|
53 * @pre aRemoteURi != 0 |
|
54 * @param aRemoteUri Remote target URI that identifies a resource that |
|
55 * the request is addressed to. The ownership is transferred. |
|
56 */ |
|
57 IMPORT_C static CSIPRequestElements* NewL(CUri8* aRemoteUri); |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 * If the URI is SIP URI, no SIP URI headers are allowed. |
|
62 * @pre aRemoteURi != 0 |
|
63 * @param aRemoteUri Remote target URI that identifies a resource that |
|
64 * the request is addressed to. The ownership is transferred. |
|
65 */ |
|
66 IMPORT_C static CSIPRequestElements* NewLC(CUri8* aRemoteUri); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 IMPORT_C ~CSIPRequestElements(); |
|
72 |
|
73 public: // New functions |
|
74 /** |
|
75 * Sets/resets the recipient's To-header |
|
76 * To-header must not contain tag-parameter. |
|
77 * @pre aTo != 0 |
|
78 * @param aTo a To-header to be set, the ownership is transferred. |
|
79 */ |
|
80 IMPORT_C void SetToHeaderL(CSIPToHeader* aTo); |
|
81 |
|
82 /** |
|
83 * Gets the recipient's To-header |
|
84 * @return To-header or a 0-pointer if not present. Ownership is not |
|
85 * transferred. |
|
86 */ |
|
87 IMPORT_C const CSIPToHeader* ToHeader() const; |
|
88 |
|
89 /** |
|
90 * Sets/resets the originator's From-header. |
|
91 * From-header must not contain tag-parameter. |
|
92 * @pre aFrom != 0 |
|
93 * @param aFrom a From-header to be set, the ownership is transferred. |
|
94 * @leave KErrArgument if aFrom == 0 |
|
95 */ |
|
96 IMPORT_C void SetFromHeaderL(CSIPFromHeader* aFrom); |
|
97 |
|
98 /** |
|
99 * Gets the originator's From-header |
|
100 * @return From-header or a 0-pointer if not present. Ownership is not |
|
101 * transferred. |
|
102 */ |
|
103 IMPORT_C const CSIPFromHeader* FromHeader() const; |
|
104 |
|
105 /** |
|
106 * Gets CSeq-header. Available for only incoming requests. |
|
107 * @return a CSeq-header or a 0-pointer if not present. |
|
108 * Ownership is not transferred. |
|
109 */ |
|
110 IMPORT_C const CSIPCSeqHeader* CSeqHeader() const; |
|
111 |
|
112 /** |
|
113 * Sets the remote URI. |
|
114 * If the URI is a SIP URI, no SIP URI headers are allowed. |
|
115 * @pre aRemoteUri != 0 |
|
116 * @param aRemoteUri |
|
117 * @leave KErrArgument if aRemoteUri==0 |
|
118 */ |
|
119 IMPORT_C void SetRemoteUriL(CUri8* aRemoteUri); |
|
120 |
|
121 /** |
|
122 * Gets the remote target URI |
|
123 * @return remote target URI |
|
124 */ |
|
125 IMPORT_C const CUri8& RemoteUri() const; |
|
126 |
|
127 /** |
|
128 * Sets the SIP request method |
|
129 * @param aMethod a SIP method name. |
|
130 * @leave KErrArgument if method name given is syntactically |
|
131 * incorrect |
|
132 */ |
|
133 IMPORT_C void SetMethodL(RStringF aMethod); |
|
134 |
|
135 /** |
|
136 * Gets the SIP Method for a request |
|
137 * @return a SIP method name or a an empty string if the method |
|
138 * is not defined |
|
139 */ |
|
140 IMPORT_C RStringF Method() const; |
|
141 |
|
142 /** |
|
143 * Gets message elements (contains all SIP user headers and content) |
|
144 * @return message elements |
|
145 */ |
|
146 IMPORT_C const CSIPMessageElements& MessageElements() const; |
|
147 |
|
148 /** |
|
149 * Gets message elements (contains all SIP user headers and content) |
|
150 * The response elements can be populated with SIP user headers |
|
151 * and content using returned reference to the message elements. |
|
152 * @return message elements |
|
153 */ |
|
154 IMPORT_C CSIPMessageElements& MessageElements(); |
|
155 |
|
156 public: // New functions, for internal use |
|
157 static CSIPRequestElements* InternalizeL (RReadStream& aReadStream); |
|
158 void ExternalizeL (RWriteStream& aWriteStream) const; |
|
159 |
|
160 private: |
|
161 CSIPRequestElements(); |
|
162 void ConstructL(CUri8* aRemoteUri); |
|
163 void DoInternalizeL(RReadStream& aReadStream); |
|
164 |
|
165 private: // Data |
|
166 RStringF iMethod; |
|
167 CUri8* iRemoteURI; |
|
168 CSIPMessageElements* iMessageElements; |
|
169 |
|
170 private: // For testing purposes |
|
171 UNIT_TEST(CSIPRequestElementsTest) |
|
172 }; |
|
173 |
|
174 #endif |