|
1 /* |
|
2 * Copyright (c) 2005 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: Makes the contents of SIP messages using SIP API. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef MCESIPEVENTHELPER_H |
|
23 #define MCESIPEVENTHELPER_H |
|
24 |
|
25 //INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <badesca.h> |
|
28 #include <sipstrings.h> |
|
29 #include <sipstrconsts.h> |
|
30 #include <sipsubscriptionstateheader.h> |
|
31 #include "mcerefer.h" |
|
32 |
|
33 // CONSTANTS |
|
34 const TUint KMceEventIdNotAssigned = 0; |
|
35 // MACROS |
|
36 |
|
37 // DATA TYPES |
|
38 |
|
39 // FUNCTION PROTOTYPES |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class CSIPMessageElements; |
|
43 class CSIPSubscribeDialogAssoc; |
|
44 class CSIPResponseElements; |
|
45 class CSIPHeaderBase; |
|
46 class CSIPEventHeader; |
|
47 class CMceSipEvent; |
|
48 class CMceComEvent; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 /** |
|
52 * Makes the contents of SIP messages using SIP API |
|
53 * |
|
54 * @lib |
|
55 * @since |
|
56 */ |
|
57 class MCESIPEventHelper |
|
58 { |
|
59 |
|
60 public: // New functions |
|
61 |
|
62 /** |
|
63 * Creates a request message elements. Leaves in error cases. |
|
64 * this is for new request-subscribe, subscribeupdate. |
|
65 * Adds user defined headers, body and content type if present and |
|
66 * expires header. |
|
67 * @param aEvent the com event |
|
68 * @param aRequestType the request type as SIP string |
|
69 * @param aExpiresValue the expiration value |
|
70 * @return CSIPMessageElements*, pointer to the created request message. |
|
71 * The ownership is transferred. |
|
72 */ |
|
73 static CSIPMessageElements* CreateMessageElementsLC( |
|
74 CMceComEvent& aEvent, |
|
75 TInt aRequestType, |
|
76 TUint aExpiresValue ); |
|
77 |
|
78 /** |
|
79 * Creates a request message elements. Leaves in error cases. |
|
80 * this is for notify request msg. |
|
81 * @param aEvent the com event |
|
82 * @param aHeaders the user headers |
|
83 * @return CSIPMessageElements*, pointer to the created request message. |
|
84 * The ownership is transferred. |
|
85 */ |
|
86 static CSIPMessageElements* CreateMessageElementsLC( |
|
87 CMceComEvent& aEvent, |
|
88 TInt aRequestType ); |
|
89 |
|
90 /** |
|
91 * Creates a request message elements. Leaves in error cases. |
|
92 * Used for REFER request. Adds user defined headers, body and |
|
93 * content type if present, and support for subscription suppression. |
|
94 * according to the givent |
|
95 * @param aEvent the com event |
|
96 * @param aRequestType the request type as SIP string |
|
97 * @param aReferType the REFER type |
|
98 * @return CSIPMessageElements*, pointer to the created request message. |
|
99 * The ownership is transferred. |
|
100 */ |
|
101 static CSIPMessageElements* CreateMessageElementsLC( |
|
102 CMceComEvent& aEvent, |
|
103 TInt aRequestType, |
|
104 CMceRefer::TType aReferType ); |
|
105 |
|
106 |
|
107 /** |
|
108 * Creates a message elements for first Notify to REFER. |
|
109 * @param aEvent the com event |
|
110 * @return CSIPMessageElements*, pointer to the created message elements. |
|
111 * The ownership is transferred. |
|
112 */ |
|
113 static CSIPMessageElements* CreateReferNotifyMessageElementsLC( |
|
114 CMceComEvent& aEvent ); |
|
115 |
|
116 /** |
|
117 * Creates response elements. The reason phrase is derived |
|
118 * from the reason code. |
|
119 * @param aEvent the com event |
|
120 * @param aReason the reason code as SIP string |
|
121 * @param aAddClientData ETrue, if there's client data to be added |
|
122 */ |
|
123 static CSIPResponseElements* CreateResponseL( |
|
124 CMceComEvent& aEvent, |
|
125 TUint aReason, |
|
126 TBool aAddClientData = EFalse ); |
|
127 |
|
128 /** |
|
129 * Creates response elements. Arbitrary reason phrase and code. |
|
130 * @param aEvent the com event |
|
131 * @param aReason the reason code, |
|
132 * @param aPhrase reason phrase |
|
133 * @param aAddClientData ETrue, if there's client data to be added |
|
134 */ |
|
135 static CSIPResponseElements* CreateResponseL( |
|
136 CMceComEvent& aEvent, |
|
137 TUint aReason, |
|
138 RStringF aPhrase, |
|
139 TBool aAddClientData = EFalse ); |
|
140 |
|
141 /** |
|
142 * Handle Expire Header |
|
143 * @param aSubscribeAssoc, the SubscribeDialogAssociation |
|
144 * @param aMessage, message elements |
|
145 * @param aTerminated, True if the expire value==0 |
|
146 * @return NULL |
|
147 */ |
|
148 static void HandleExpireHeaderL( const CSIPMessageElements& aMessage, |
|
149 TBool& aTerminated ); |
|
150 /** |
|
151 * Handle SubscriptionState Header |
|
152 * @param aMessage, message elements |
|
153 * @return NULL |
|
154 */ |
|
155 static void HandleSubscriptionStateHeaderL( |
|
156 const CSIPMessageElements& aMessage, |
|
157 TBool& aTerminated); |
|
158 |
|
159 |
|
160 /** |
|
161 * Creates a response to given request |
|
162 * @param aEvent the com event |
|
163 * @param aMessage, a request message which response is created from. |
|
164 * @return CSIPResponseElements*, pointer to the created request message. |
|
165 * The ownership is transferred. |
|
166 */ |
|
167 static CSIPResponseElements* NotifyRequestReceivedLC( |
|
168 CMceComEvent& aEvent, |
|
169 const CSIPMessageElements& aMessage ); |
|
170 |
|
171 /** |
|
172 * Creates a response to given refer request |
|
173 * @param aEvent the com event |
|
174 * @param aMessage, a request message which response is created from. |
|
175 * @return CSIPResponseElements*, pointer to the created request message. |
|
176 * The ownership is transferred. |
|
177 */ |
|
178 static CSIPResponseElements* ReferNotifyRequestReceivedLC( |
|
179 CMceComEvent& aEvent, |
|
180 const CSIPMessageElements& aMessage ); |
|
181 |
|
182 /** |
|
183 * Creates a response to given request |
|
184 * @param aEvent the com event |
|
185 * @param aMessage, a request message which response is created from. |
|
186 * @return CSIPResponseElements*, pointer to the created request message. |
|
187 * The ownership is transferred. |
|
188 */ |
|
189 static CSIPResponseElements* SubscribeRequestReceivedLC( |
|
190 CMceComEvent& aEvent, |
|
191 const CSIPMessageElements& aMessage ); |
|
192 |
|
193 /** |
|
194 * Resolves the REFER type from message elements. |
|
195 * @param aMessage, a message to be resolved. |
|
196 * @return CMceRefer::TType, the REFER type. |
|
197 */ |
|
198 static CMceRefer::TType ResolveReferTypeL( const CSIPMessageElements& aMessage ); |
|
199 |
|
200 /** |
|
201 * Matches the given Event headers. They match, if the event |
|
202 * packages are same and either id params are the same or |
|
203 * none of them has id param. |
|
204 * @param aFirstEvent first event to be compared |
|
205 * @param aSecondEvent secnd event to be compared |
|
206 * @return ETrue if events match |
|
207 */ |
|
208 static TBool MatchEvents( const CSIPEventHeader& aFirstEvent, |
|
209 const CSIPEventHeader& aSecondEvent ); |
|
210 |
|
211 /** |
|
212 * Matches the given event package and id to the given |
|
213 * Event header. This is a match, if the event packages |
|
214 * are the same and the id param is either not present in the |
|
215 * Event header or matches the given value, which in this case |
|
216 * must be greater than 0. |
|
217 * @param aEvent the Event header |
|
218 * @param aEventPackage the event package |
|
219 * @param aIdValue the value of id param. |
|
220 */ |
|
221 static TBool MatchEventsL( const TDesC8& aEventPackage, |
|
222 TUint aIdValue, |
|
223 const CSIPEventHeader& aEvent ); |
|
224 |
|
225 |
|
226 |
|
227 /** |
|
228 * Set Subscription header State value and parameters |
|
229 * if there is MsgHeader set by client then the value will be |
|
230 * set as client specified |
|
231 * @param aEvent the Event header |
|
232 * @param aRequestType type of request |
|
233 * @param aSubStateHeader the header will be set to |
|
234 * @param aSubStateValue subscription state default value ex termiante |
|
235 * @param aExpireParam default expire value |
|
236 * @param aTerminating if it is setting to terminating state |
|
237 */ |
|
238 static void SetSubsStateHeaderValueAndParamsL( |
|
239 CMceComEvent& aEvent, |
|
240 TInt aRequestType, |
|
241 CSIPSubscriptionStateHeader& aSubStateHeader, |
|
242 const TDesC8& aSubStateValue, |
|
243 TUint32 aExpireParam, |
|
244 TBool aTerminating = ETrue ); |
|
245 |
|
246 private: // New functions |
|
247 |
|
248 /** |
|
249 * To Check if the request ContentType is valid |
|
250 * @param aMessage, the request message to be checked |
|
251 * @return Etrue or EFalse |
|
252 */ |
|
253 static TBool ReferContentTypeOK( const CSIPMessageElements& aMessage ); |
|
254 |
|
255 /** |
|
256 * To Check if the request SubscriptionState header is valid |
|
257 * @param aMessage, the request message to be checked |
|
258 * @return Etrue or EFalse |
|
259 */ |
|
260 static TBool SubscriptionStateOK( const CSIPMessageElements& aMessage ); |
|
261 |
|
262 /** |
|
263 * To Check if the request Event header is valid |
|
264 * @param aMessage, the request message to be checked |
|
265 * @return Etrue or EFalse |
|
266 */ |
|
267 static TBool EventOK( const CSIPMessageElements& aMessage ); |
|
268 |
|
269 /** |
|
270 * To Check if the request Event header is valid |
|
271 * @param aMessage, the request message to be checked |
|
272 * @return Etrue or EFalse |
|
273 */ |
|
274 static TBool ReferEventOK( const CSIPMessageElements& aMessage ); |
|
275 |
|
276 /** |
|
277 * Creates a request message elements. Adds content type and content |
|
278 * if present. |
|
279 * @param aEvent the com event containing the data |
|
280 * @return CSIPMessageElements*, pointer to the created request message. |
|
281 * The ownership is transferred. |
|
282 */ |
|
283 static void SetContentL( CSIPMessageElements& aMsgElem, |
|
284 CMceComEvent& aEvent ); |
|
285 |
|
286 |
|
287 /** |
|
288 * sets a subscription-state header from aMsgHeader |
|
289 * function leaves if the subscription header in MsgHeader is malformate |
|
290 * @param aMsgHeader headers set by client |
|
291 * @param aHeaderIndex the index where subscription state located, |
|
292 * @param aSubStateHeader subscription state header which will be set to |
|
293 */ |
|
294 static void SetSSHeaderValueAndParamL( |
|
295 const MDesC8Array& aMsgHeader, |
|
296 TUint aHeaderIndex, |
|
297 CSIPSubscriptionStateHeader& aSubStateHeader ); |
|
298 |
|
299 |
|
300 /** |
|
301 * Check if there is subscription state header from |
|
302 * ComEvent MsgHeader |
|
303 * @param aEvent the Event header |
|
304 * @param aRequestType requestType |
|
305 * @return ETrue or EFalse |
|
306 */ |
|
307 static TBool HasSubscriptionStateHeader( CMceComEvent& aEvent, |
|
308 TInt aRequestType, |
|
309 TInt aIndex ); |
|
310 private: // EUNIT |
|
311 |
|
312 friend class UT_MCESIPEventHelper; |
|
313 }; |
|
314 |
|
315 #endif // MCESIPEVENTHELPER_H |
|
316 |
|
317 // End of File |