|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MCESIP_H |
|
22 #define MCESIP_H |
|
23 |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <bamdesca.h> |
|
27 #include <badesca.h> |
|
28 #include <sipresponseelements.h> |
|
29 #include <sipmessageelements.h> |
|
30 #include <siprequestelements.h> |
|
31 #include <sipservertransaction.h> |
|
32 #include <sipclienttransaction.h> |
|
33 #include <sipaddress.h> |
|
34 #include <sipfromheader.h> |
|
35 #include <sipextensionheader.h> |
|
36 #include <siperr.h> |
|
37 #include <sipstrings.h> |
|
38 #include <sipstrconsts.h> |
|
39 #include <uri8.h> |
|
40 #include <sipcontenttypeheader.h> |
|
41 #include "mceserial.h" |
|
42 #include "mcesipextensions.h" |
|
43 |
|
44 // FORWARD DECLARATION |
|
45 |
|
46 class CSdpDocument; |
|
47 class CSIPDialog; |
|
48 class CSIPContactHeader; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 |
|
52 |
|
53 enum TMceSipResponseType |
|
54 { |
|
55 E1XX, |
|
56 E2XX, |
|
57 E3XX, |
|
58 E4XX, |
|
59 E5XX, |
|
60 E6XX |
|
61 }; |
|
62 |
|
63 //E1XX, |
|
64 const TUint KMceSipTrying = 100; |
|
65 const TUint KMceSipRinging = 180; |
|
66 const TUint KMceSipCallIsBeingForwarded = 181; |
|
67 const TUint KMceSipQueued = 182; |
|
68 const TUint KMceSipSessionProgress = 183; |
|
69 |
|
70 //E2XX, |
|
71 const TUint KMceSipOK = 200; |
|
72 const TUint KMceSipAccepted = 202; |
|
73 |
|
74 //E3XX, |
|
75 const TUint KMceSipMultipleChoices = 300; |
|
76 const TUint KMceSipMovedPermanently = 301; |
|
77 const TUint KMceSipMovedTemporarily = 302; |
|
78 const TUint KMceSipUseProxy = 305; |
|
79 const TUint KMceSipAlternativeService = 380; |
|
80 |
|
81 //E4XX, |
|
82 const TInt KMceSipBadRequest = 400; |
|
83 const TUint KMceSipUnauthorized = 401; |
|
84 const TUint KMceSipPaymentRequired = 402; |
|
85 const TUint KMceSipForbidden = 403; |
|
86 const TUint KMceSipNotFound = 404; |
|
87 const TUint KMceSipMethodNotAllowed = 405; |
|
88 const TUint KMceSip4XXNotAcceptable = 406; |
|
89 const TUint KMceSipProxyAuthenticationRequired = 407; |
|
90 const TUint KMceSipRequestTimeout = 408; |
|
91 const TUint KMceSipGone = 410; |
|
92 const TUint KMceSipequestEntityTooLarge = 413; |
|
93 const TUint KMceSipRequestURITooLong = 414; |
|
94 const TUint KMceSipUnsupportedMediaType = 415; |
|
95 const TUint KMceSipUnsupportedURIScheme = 416; |
|
96 const TUint KMceSipBadExtension = 420; |
|
97 const TUint KMceSipExtensionRequired = 421; |
|
98 const TUint KMceSipSessionIntervalTooSmall = 422; |
|
99 const TUint KMceSipIntervalTooBrief = 423; |
|
100 const TUint KMceSipTemporarilyUnavailable = 480; |
|
101 const TUint KMceSipCallOrTransactionDoesNotExist = 481; |
|
102 const TUint KMceSipLoopDetected = 482; |
|
103 const TUint KMceSipTooManyHops = 483; |
|
104 const TUint KMceSipAddressIncomplete = 484; |
|
105 const TUint KMceSipAmbiguous = 485; |
|
106 const TUint KMceSipBusyHere = 486; |
|
107 const TUint KMceSipRequestTerminated = 487; |
|
108 const TUint KMceSipNotAcceptableHere = 488; |
|
109 const TUint KMceSipBadEvent = 489; |
|
110 const TUint KMceSipRequestPending = 491; |
|
111 const TUint KMceSipUndecipherable = 493; |
|
112 |
|
113 const TUint KMceSipRefreshInterval = 60; |
|
114 |
|
115 |
|
116 //E5XX, |
|
117 const TUint KMceSipServerInternalError = 500; |
|
118 const TUint KMceSipNotImplemented = 501; |
|
119 const TUint KMceSipBadGateway = 502; |
|
120 const TUint KMceSipServiceUnavailable = 503; |
|
121 const TUint KMceSipServerTimeOut = 504; |
|
122 const TUint KMceSipVersionNotSupported = 505; |
|
123 const TUint KMceSipMessageTooLarge = 513; |
|
124 //580 Precondition Failure: |
|
125 const TInt KMceSipPreconditionFailure = 580; |
|
126 |
|
127 //E6XX, |
|
128 const TUint KMceSipBusyEverywhere = 600; |
|
129 const TUint KMceSipDecline = 603; |
|
130 const TUint KMceSipDoesNotExistAnywhere = 604; |
|
131 const TUint KMceSip6XXNotAcceptable = 606; |
|
132 |
|
133 |
|
134 |
|
135 typedef TUint TMceSipWarningCode; |
|
136 |
|
137 //300 Incompatible network protocol: One or more network protocols |
|
138 //contained in the session description are not available. |
|
139 const TMceSipWarningCode KMceSipWarnIncompatibleNetworkProtocol = 300; |
|
140 |
|
141 //301 Incompatible network address formats: One or more network |
|
142 //address formats contained in the session description are not |
|
143 //available. |
|
144 const TMceSipWarningCode KMceSipWarnIncompatibleNetworkAddressFormat = 301; |
|
145 |
|
146 //302 Incompatible transport protocol: One or more transport |
|
147 //protocols described in the session description are not available. |
|
148 const TMceSipWarningCode KMceSipWarnIncompatibleTransportProtocol = 302; |
|
149 |
|
150 //303 Incompatible bandwidth units: One or more bandwidth |
|
151 //measurement units contained in the session description were not understood. |
|
152 const TMceSipWarningCode KMceSipWarnIncompatibleBandwidthUnits = 303; |
|
153 |
|
154 //304 Media type not available: One or more media types |
|
155 //contained in the session description are not available. |
|
156 const TMceSipWarningCode KMceSipWarnMediaTypeNotAvailable = 304; |
|
157 |
|
158 //305 Incompatible media format: One or more media |
|
159 //formats contained in the session description are not available. |
|
160 const TMceSipWarningCode KMceSipWarnIncompatibleMediaFormat = 305; |
|
161 |
|
162 //306 Attribute not understood: One or more of the media |
|
163 //attributes in the session description are not supported. |
|
164 const TMceSipWarningCode KMceSipWarnAttributeNotUnderstood = 306; |
|
165 |
|
166 //307 Session description parameter not understood: A parameter |
|
167 //other than those listed above was not understood. |
|
168 const TMceSipWarningCode KMceSipWarnSessionDescriptionParameterNotUnderstood = 307; |
|
169 |
|
170 //330 Multicast not available: The site where the user is located |
|
171 //does not support multicast. |
|
172 const TMceSipWarningCode KMceSipWarnMulticastNotAvailable = 330; |
|
173 |
|
174 //331 Unicast not available: The site where the user is located does |
|
175 //not support unicast communication (usually due to the presence of a firewall). |
|
176 const TMceSipWarningCode KMceSipWarnUnicastNotAvailable = 331; |
|
177 |
|
178 //370 Insufficient bandwidth: The bandwidth specified in the session |
|
179 //description or defined by the media exceeds that known to be available. |
|
180 const TMceSipWarningCode KMceSipWarnInsufficientBandwidth = 370; |
|
181 |
|
182 //399 Miscellaneous warning: The warning text can include arbitrary |
|
183 //information to be presented to a human user or logged. A system receiving |
|
184 //this warning MUST NOT take any automated action. |
|
185 const TMceSipWarningCode KMceSipWarnMiscellaneous = 399; |
|
186 |
|
187 const TChar KMceSipSeparator = ':'; |
|
188 const TChar KMceSipHeaderSeparator = ';'; |
|
189 const TChar KMceSipEqualsTo = '='; |
|
190 const TChar KMceSipAt = '@'; |
|
191 const TChar KMceSipBlank = ' '; |
|
192 const TChar KMceSipDash = '-'; |
|
193 |
|
194 _LIT8( KMceSipNullAddress, "0.0.0.0" ); |
|
195 _LIT8( KMceSipNullAddressA, "c=IN IP4 0.0.0.0\n" ); |
|
196 _LIT8( KMceSipPhraseRequestPending, "Request Pending"); |
|
197 _LIT8( KMceSipPhraseAccepted, "Accepted" ); |
|
198 |
|
199 _LIT8( KMceSipWarnPhrase300, "Incompatible network protocol"); |
|
200 _LIT8( KMceSipWarnPhrase301, "Incompatible network address formats"); |
|
201 _LIT8( KMceSipWarnPhrase302, "Incompatible transport protocol"); |
|
202 _LIT8( KMceSipWarnPhrase303, "Incompatible bandwidth units"); |
|
203 _LIT8( KMceSipWarnPhrase304, "Media type not available"); |
|
204 _LIT8( KMceSipWarnPhrase305, "Incompatible media format"); |
|
205 _LIT8( KMceSipWarnPhrase306, "Attribute not understood"); |
|
206 _LIT8( KMceSipWarnPhrase307, "Session description parameter not understood"); |
|
207 _LIT8( KMceSipWarnPhrase330, "Multicast not available"); |
|
208 _LIT8( KMceSipWarnPhrase331, "Unicast not available"); |
|
209 _LIT8( KMceSipWarnPhrase370, "Insufficient bandwidth"); |
|
210 _LIT8( KMceSipWarnPhrase399, "Miscellaneous warning"); |
|
211 _LIT8( KMceSipErrPhrase580, "Precondition Failure"); |
|
212 |
|
213 _LIT8( KMceSipWarningPattern, "%d %S %S"); |
|
214 _LIT8( KMceSipContentTypePattern, "%S/%S"); |
|
215 _LIT8( KMceSipContactURIPattern, "sip:%S@localhost" ); |
|
216 _LIT8( KMceSipSdpSegPrecCurrentStatusPattern, "qos %S %S" ); |
|
217 _LIT8( KMceSipSdpSegPrecDesiredStatusPattern, "qos %S %S %S" ); |
|
218 |
|
219 |
|
220 _LIT8( KMceSipSdpSecPrecCurrentStatusPattern, "sec %S %S" ); |
|
221 _LIT8( KMceSipSdpSecPrecDesiredStatusPattern, "sec %S %S %S" ); |
|
222 |
|
223 |
|
224 _LIT8( KMceSipWarning, "Warning" ); |
|
225 _LIT8( KMceSipTimer, "timer" ); |
|
226 _LIT8( KMceSipRefresher, "refresher" ); |
|
227 _LIT8( KMceSipRefresherUAC, "uac" ); |
|
228 _LIT8( KMceSipRefresherUAS, "uas" ); |
|
229 _LIT8( KMceSipSdpQos, "qos" ); |
|
230 _LIT8( KMceSipSdpSec, "sec" ); |
|
231 _LIT8( KMceSipSdpPreconditionCurr, "curr" ); |
|
232 _LIT8( KMceSipSdpPreconditionDes, "des" ); |
|
233 _LIT8( KMceSipSdpQosNone, "none" ); |
|
234 _LIT8( KMceSipEventPackageRefer, "refer" ); |
|
235 _LIT8( KMceSipStateActive, "active" ); |
|
236 _LIT8( KMceSipStatePending, "pending" ); |
|
237 _LIT8( KMceSipStateTerminated, "terminated" ); |
|
238 _LIT8( KMceSipReferEventName, "refer" ); |
|
239 _LIT8( KMceSipReferAcceptType, "message" ); |
|
240 _LIT8( KMceSipReferAcceptSubtype, "sipfrag" ); |
|
241 _LIT8( KMceSipVersion, "version" ); |
|
242 _LIT8( KMceSipNotifyContent, "SIP/2.0 100 Trying\r\n" ); |
|
243 _LIT8( KMceSipValueNoReferSub, "norefersub"); |
|
244 _LIT8( KMceSipValueMultipleRefer,"multiple-refer" ); |
|
245 _LIT8( KMceSipValueFalse, "false" ); |
|
246 _LIT8( KMceSipHeaderReferSub, "Refer-Sub" ); |
|
247 _LIT8( KMceSipHeaderSessionExpires, "Session-Expires" ); |
|
248 _LIT8( KMceSipHeaderCompactFormOfSessionExpires, "x" ); |
|
249 _LIT8( KMceSipHeaderMinSE, "Min-SE" ); |
|
250 _LIT8( KMceSipMediaTypeApplication, "application" ); |
|
251 _LIT8( KMceSipMediaSubTypeSDP, "sdp" ); |
|
252 _LIT8( KMceSipMPartMediaTypeMultipart, "multipart" ); |
|
253 _LIT8( KMceSipMPartMediaSubTypeMixed, "mixed" ); |
|
254 _LIT8( KMceSipMPartBoundary, "boundary" ); |
|
255 _LIT8( KMceSipMPartMessageBoundary, "MessageBoundary" ); |
|
256 _LIT8( KMceSipMPartMessagePattern, |
|
257 "--MessageBoundary\r\n\ |
|
258 Content-Type: application/sdp\r\n\r\n\ |
|
259 %S\r\n\ |
|
260 --MessageBoundary\r\n\ |
|
261 Content-Type: %S\r\n\r\n\ |
|
262 %S\ |
|
263 --MessageBoundary--\r\n"); |
|
264 |
|
265 _LIT8( KMceSipSubscriptionStateHeader, "Subscription-State" ); |
|
266 _LIT8( KMceSipTransportTLS, "transport=tls"); |
|
267 _LIT8( KMceSipUriSchemeSIPs, "sips"); |
|
268 _LIT8( KMceSdpAttrRtcp, "rtcp" ); |
|
269 _LIT8( KMceSdpSpace, " " ); |
|
270 |
|
271 // Extensions |
|
272 _LIT8( KMceSip100Rel,"100rel" ); |
|
273 _LIT8( KMceSipPrecondition, "precondition" ); |
|
274 |
|
275 const TInt KMceRandMaxRetryValue = 10; |
|
276 const TInt KMceRandMinRetryValue = 1; |
|
277 const TInt KMceRandDividerOne = 1000000; |
|
278 const TInt KMceRandDividerTwo = 1000; |
|
279 |
|
280 const TBool KMceUseRetryAfter = ETrue; |
|
281 const TBool KMceNoRetryAfter = EFalse; |
|
282 |
|
283 // Time Conversion. |
|
284 const TUint KConversionMilliToMicro = 1000; |
|
285 const TUint KMceOneSecondAsMicros( 1000000 ); |
|
286 _LIT8( KMceSdpAttributeLineMarker, "a=" ); |
|
287 _LIT8( KMceSdpBandwidthLineMarker, "b=" ); |
|
288 |
|
289 /** |
|
290 * Static library providing basic helper methods |
|
291 * to handle SIP API related issues |
|
292 * |
|
293 * @lib |
|
294 * @since |
|
295 */ |
|
296 class MceSip |
|
297 { |
|
298 |
|
299 public://transaction related |
|
300 |
|
301 /** |
|
302 * Returns method of server transaction (request) |
|
303 * @param aRequest the server transaction |
|
304 * @return method of server transaction |
|
305 */ |
|
306 static RStringF Method( CSIPServerTransaction& aRequest ); |
|
307 |
|
308 /** |
|
309 * Returns response code of client transaction (response) |
|
310 * @param aResponse the client transaction |
|
311 * @return response code (1XX-6XX) |
|
312 */ |
|
313 static TUint ResponseCode( CSIPClientTransaction& aResponse ); |
|
314 |
|
315 /** |
|
316 * Returns response type |
|
317 * @param aResponse the client transaction |
|
318 * @return response type (1XX-6XX) |
|
319 */ |
|
320 static TMceSipResponseType ResponseType( |
|
321 CSIPClientTransaction& aResponse ); |
|
322 /** |
|
323 * Returns response type |
|
324 * @param aCode the response type |
|
325 * @return response type (1XX-6XX) |
|
326 */ |
|
327 static TMceSipResponseType ResponseType( TUint aCode ); |
|
328 |
|
329 /** |
|
330 * Checks if client transction is response to method |
|
331 * @param aResponse the client transaction |
|
332 * @param aMethod the method |
|
333 * @return ETrue, if client transctions is response to method |
|
334 */ |
|
335 static TBool IsResponseTo( CSIPClientTransaction& aResponse, |
|
336 RStringF aMethod ); |
|
337 |
|
338 /** |
|
339 * Returns transaction's state |
|
340 * @param aTransaction the transaction |
|
341 * @return transaction's state |
|
342 */ |
|
343 static CSIPTransactionBase::TState TrxState( |
|
344 CSIPTransactionBase& aTransaction ); |
|
345 |
|
346 /** |
|
347 * Returns ETrue, if transaction is completed |
|
348 * @param aTransaction the transaction |
|
349 * @return ETrue, if transaction is completed |
|
350 */ |
|
351 static TBool TrxCompleted( CSIPTransactionBase& aTransaction ); |
|
352 |
|
353 /** |
|
354 * Returns transaction's type as an index to string pool |
|
355 * @param aTransaction the transaction |
|
356 * @return transaction's type as an index to string pool |
|
357 */ |
|
358 static TInt TrxType( CSIPTransactionBase& aTransaction ); |
|
359 |
|
360 |
|
361 /** |
|
362 * Returns SIP message elements from transaction |
|
363 * @param aTransaction the transaction |
|
364 * @return SIP message elements |
|
365 */ |
|
366 static const CSIPMessageElements* ToMessageElements( |
|
367 CSIPTransactionBase& aTransaction ); |
|
368 |
|
369 /** |
|
370 * Checks the content of transaction |
|
371 * @param aTransaction the transaction |
|
372 * @return ETrue, if there is a content |
|
373 */ |
|
374 static TBool HasContent( CSIPTransactionBase& aTransaction ); |
|
375 |
|
376 |
|
377 /** |
|
378 * Checks whether the message contains the certain header with |
|
379 * certain value. |
|
380 * @param aMessage message that header where to be found from. |
|
381 * @param aHeaderName headername as string pool index |
|
382 * @param aHeaderValue the value to be searched |
|
383 * @return ETrue, if given header with given value is present. |
|
384 */ |
|
385 static TBool HasHeaderValueL( const CSIPMessageElements& aMessage, |
|
386 TInt aHeaderName, |
|
387 const TDesC8& aHeaderValue ); |
|
388 |
|
389 /** |
|
390 * Checks whether the user headers contains the certain header with |
|
391 * certain value. |
|
392 * @param aHeaders user header that specific header where to be found from. |
|
393 * @param aHeaderName headername as string pool index |
|
394 * @param aHeaderValue the value to be searched |
|
395 * @return ETrue, if given header with given value is present. |
|
396 */ |
|
397 static TBool HasHeaderValueL( const RPointerArray<CSIPHeaderBase>& aHeaders, |
|
398 TInt aHeaderName, |
|
399 const TDesC8& aHeaderValue ); |
|
400 /** |
|
401 * Finds Specific Headers |
|
402 * @param aMessage message that header where to be found from. |
|
403 * @param aHeaderName headername which want to be found in the message. |
|
404 * @param aHeaders array for which the found headers are added. |
|
405 * ownership of the objects is not transfered, |
|
406 */ |
|
407 static void FindHeadersL( const CSIPMessageElements& aMessage, |
|
408 RStringF aHeaderName, |
|
409 RPointerArray<CSIPHeaderBase>& aHeaders ); |
|
410 |
|
411 /** |
|
412 * Compare remote uri with EUriScheme, EUriUserinfo and EUriHost. |
|
413 * @param aRemoteUriOne, a remoteUri to be compared. |
|
414 * @param aRemoteUriTwo, a remoteUri to be compared. |
|
415 * @return An integer value of zero if the components are the same, |
|
416 * any other value if the components are not the same. |
|
417 */ |
|
418 static TInt CompareUri( const CUri8& aRemoteUriOne, const CUri8& aRemoteUriTwo ); |
|
419 |
|
420 public://SIP string pool related |
|
421 |
|
422 /** |
|
423 * Returns reson phrase based on status (reponse) code |
|
424 * @param aStatusCode status code |
|
425 * @return reson phrase. Ownership is transferred |
|
426 */ |
|
427 static RStringF ReasonPhraseL( TUint aStatusCode ); |
|
428 |
|
429 /** |
|
430 * Returns warning phrase based on warning code |
|
431 * @param aWarnCode warning code |
|
432 * @return warning phrase. Ownership is transferred |
|
433 */ |
|
434 static RStringF WarningPhraseL( TUint aWarnCode ); |
|
435 |
|
436 /** |
|
437 * Returns index of SIP string pool if given string is |
|
438 * found from the pool |
|
439 * @param aSIPString a string |
|
440 * @return index of SIP string pool, KErrNotFound is |
|
441 * returned if string is not found |
|
442 */ |
|
443 static TInt SIPStringIndex( const TDesC8& aSIPString ); |
|
444 |
|
445 |
|
446 public://header manipulation |
|
447 |
|
448 /** |
|
449 * Finds Specific Header |
|
450 * @param aMessage message that header where to be found from. |
|
451 * @param aHeaderName headername which want to be found in the message. |
|
452 * @return pointer to the created request message. The |
|
453 * ownership is not transferred. |
|
454 */ |
|
455 static CSIPHeaderBase* FindHeader( const CSIPMessageElements& aMessage, |
|
456 RStringF aHeaderName ); |
|
457 |
|
458 /** |
|
459 * Finds Specific Header |
|
460 * @param aHeaders headers that specific header where to be found from. |
|
461 * @param aHeaderName headername which want to be found in the message. |
|
462 * @return pointer to the created request message. The |
|
463 * ownership is not transferred. |
|
464 */ |
|
465 static CSIPHeaderBase* FindHeader( const RPointerArray<CSIPHeaderBase>& aHeaders , |
|
466 RStringF aHeaderName ); |
|
467 /** |
|
468 * Converts SIP address to text |
|
469 * @param aToAddr SIP Address |
|
470 * @return SIP address as text |
|
471 * ownership is transferred. |
|
472 */ |
|
473 static HBufC8* AddressToTextL( const CSIPAddress& aToAddr ); |
|
474 |
|
475 /** |
|
476 * Converts SIP address to text |
|
477 * @param aToAddr SIP Address |
|
478 * @return SIP address as text |
|
479 * ownership is transferred. |
|
480 */ |
|
481 static CDesC8Array* UserHeadersToTextArrayL( |
|
482 CSIPTransactionBase& aTransaction, |
|
483 const CSIPDialog& aDialog ); |
|
484 |
|
485 /** |
|
486 * Converts SIP from address to from header |
|
487 * @param aAddress SIP Address as text |
|
488 * @return SIP address as SIP from header |
|
489 * ownership is transferred. |
|
490 */ |
|
491 static CSIPFromHeader* ToFromHeaderL( const TDesC8& aAddress ); |
|
492 |
|
493 /** |
|
494 * Converts header string array to SIP header arrays |
|
495 * @param aSIPHeaders SIP header array to fill |
|
496 * @param aHeaders string array |
|
497 */ |
|
498 static void ToSIPExtensionHeadersL( |
|
499 RPointerArray<CSIPHeaderBase>& aSIPHeaders, |
|
500 const MDesC8Array& aHeaders ); |
|
501 |
|
502 /** |
|
503 * Converts content type to SIP content type header |
|
504 * @param aContentType enum type to define if content type is predefined |
|
505 * such as application/sdp or user defined |
|
506 * @param aUserDefinedContentType if user defined content type, content type |
|
507 * as text |
|
508 * @return SIP content type header |
|
509 */ |
|
510 static CSIPContentTypeHeader* ToContentTypeHeaderL( |
|
511 TMceContentType aContentType, |
|
512 const HBufC8* aUserDefinedContentType = NULL ); |
|
513 |
|
514 /** |
|
515 * Creates a Supported header for given extension and adds it |
|
516 * to the header array. |
|
517 * @param aSIPHeaders SIP header array |
|
518 * @param aExtension the extension to be supported. |
|
519 */ |
|
520 |
|
521 static void AddSupportedHeaderL( RPointerArray<CSIPHeaderBase>& aSIPHeaders, |
|
522 const TDesC8& aExtension ); |
|
523 |
|
524 /** |
|
525 * Creates a Require header for given extension and adds it |
|
526 * to the header array. |
|
527 * @param aSIPHeaders SIP header array |
|
528 * @param aExtension the extension to be required. |
|
529 */ |
|
530 |
|
531 static void AddRequireHeaderL( RPointerArray<CSIPHeaderBase>& aSIPHeaders, |
|
532 const TDesC8& aExtension ); |
|
533 |
|
534 /** |
|
535 * Creates an Allow header for given method and adds it |
|
536 * to the header array. |
|
537 * @param aSIPHeaders SIP header array |
|
538 * @param aMethod the method to be allowed. |
|
539 */ |
|
540 static void AddAllowHeaderL( RPointerArray<CSIPHeaderBase>& aSIPHeaders, |
|
541 TInt aMethod ); |
|
542 |
|
543 /** |
|
544 * Creates a RAck header for given client transaction and adds it |
|
545 * to the header array. |
|
546 * @param aSIPHeaders SIP header array |
|
547 * @param aMethod the method. |
|
548 */ |
|
549 static void AddRAckHeaderL( RPointerArray<CSIPHeaderBase>& aSIPHeaders, |
|
550 const CSIPResponseElements& aResponse ); |
|
551 |
|
552 /** |
|
553 * Converts "Contact"-header including the whole value of the header |
|
554 * except for the header's name ("Contact:") to SIP contact header |
|
555 * @param aContact value for contact header |
|
556 * @return SIP contect header |
|
557 * ownership is transferred. |
|
558 */ |
|
559 static CSIPContactHeader* ToContactHeaderL( const TDesC8& aContact ); |
|
560 |
|
561 /** |
|
562 * Add sip methods to array for allow header |
|
563 * @param aArray array that thoses methods are added to |
|
564 * @return void |
|
565 */ |
|
566 static void BasicAllowMethodsL( RArray<TInt>& aArray ); |
|
567 |
|
568 /** |
|
569 * Find If "Contact"-header including SIPs URI in user headers |
|
570 * @param aMessage message response element including contact header |
|
571 * @return True if contact headers has SIPs URI, false otherwise |
|
572 */ |
|
573 static TBool HasSipsUriInContactL( const CSIPMessageElements& aMessage ); |
|
574 |
|
575 /** |
|
576 * Find If "Contact"-header including SIPs URI in user headers |
|
577 * @param aMessage message response element including contact header |
|
578 * @return True if contact headers has SIPs URI, false otherwise |
|
579 */ |
|
580 static TBool HasTlsInContactL( const CSIPMessageElements& aMessage ); |
|
581 |
|
582 |
|
583 public://error situation handling |
|
584 |
|
585 /** |
|
586 * Returns response code and reason phrase based on given |
|
587 * error. |
|
588 * @param aError error |
|
589 * @param aSIPResponseCode reference of response code |
|
590 * @param aReasonPhrase reference of reason phrase pool index |
|
591 */ |
|
592 static void ErrorResponse( TInt aError, |
|
593 TUint& aSIPResponseCode, |
|
594 TInt& aReasonPhrase ); |
|
595 |
|
596 /** |
|
597 * Returns ETrue, if error is SDP related error |
|
598 * @param aError error code |
|
599 * @return ETrue, if error is SDP related error |
|
600 */ |
|
601 static TBool IsSDPError( TInt aError ); |
|
602 |
|
603 /** |
|
604 * Returns ETrue, if error is SIP API related error |
|
605 * @param aError error code |
|
606 * @return ETrue, if error is SIP API related error |
|
607 */ |
|
608 static TBool IsSIPStackError( TInt aError ); |
|
609 |
|
610 |
|
611 /** |
|
612 * Discards request by sending response, which is resolved based |
|
613 * on given error. If error is greater it is interpreted as |
|
614 * response code, which will be sent as response. By default |
|
615 * 500 is sent as response. |
|
616 * @param aRequest discarded request. Ownership is transferred |
|
617 * @param aError error |
|
618 * @param aRetryIndication if ETrue, Retry-After header is included |
|
619 * in response |
|
620 * @return status of operation |
|
621 */ |
|
622 static TInt DiscardRequest( CSIPServerTransaction* aRequest, |
|
623 TInt aError = KErrNone, |
|
624 TBool aRetryIndication = EFalse ); |
|
625 |
|
626 /** |
|
627 * Discards request by sending response, which is resolved based |
|
628 * on given error. If error is greater it is interpreted as |
|
629 * response code, which will be sent as response. By default |
|
630 * 500 is sent as response. |
|
631 * @param aRequest discarded request. |
|
632 * @param aError error |
|
633 * @param aRetryIndication if ETrue, Retry-After header is included |
|
634 * in response |
|
635 * @return status of operation |
|
636 */ |
|
637 static TInt DiscardRequest( CSIPServerTransaction& aRequest, |
|
638 TInt aError = KErrNone, |
|
639 TBool aRetryIndication = EFalse ); |
|
640 |
|
641 public://misc |
|
642 |
|
643 /** |
|
644 * Gives random value between two values |
|
645 * @param aMinValue min value of random value |
|
646 * @param aMaxValue max value of random value |
|
647 * @return random value |
|
648 */ |
|
649 static TUint Random( TUint aMinValue, TUint aMaxValue ); |
|
650 |
|
651 |
|
652 /** |
|
653 * Returns first integer value from header |
|
654 * @param aHeader SIP header as text |
|
655 * @return integer value |
|
656 */ |
|
657 static TUint HeaderValueL( TPtr8 aHeader ); |
|
658 |
|
659 |
|
660 public: // mics functions |
|
661 |
|
662 /** |
|
663 * Returns RSeq value from the ResponseElements |
|
664 * @param aResponseElements SIP Respomse Elements. |
|
665 * @return integer value |
|
666 */ |
|
667 |
|
668 static TInt RSeq( const CSIPResponseElements& aResponseElements ); |
|
669 |
|
670 |
|
671 private: |
|
672 |
|
673 static void DoDiscardRequestL( CSIPServerTransaction& aRequest, |
|
674 TInt aError, |
|
675 TBool aRetryIndication ); |
|
676 |
|
677 }; |
|
678 |
|
679 |
|
680 #endif |
|
681 |
|
682 // End of File |
|
683 |