|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : CSIPClientConnection.cpp |
|
15 // Part of : SIPClient |
|
16 // Version : SIP/6.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include "sipclientserver.h" |
|
23 #include "sipclientconnection.h" |
|
24 #include "sipclient.h" |
|
25 #include "RSIPConnection.h" |
|
26 #include "CSIPITCSender.h" |
|
27 #include "CSIPClientConnectionReceiver.h" |
|
28 #include "sipmessageelements.h" |
|
29 #include "siprequestelements.h" |
|
30 #include "sipresponseelements.h" |
|
31 #include "siptoheader.h" |
|
32 #include "sipfromheader.h" |
|
33 #include "sipcontactheader.h" |
|
34 #include "sipexpiresheader.h" |
|
35 #include "siptoheader.h" |
|
36 #include "siprouteheader.h" |
|
37 #include "sipcallidheader.h" |
|
38 #include "sipaddress.h" |
|
39 #include "uricontainer.h" |
|
40 #include "sipuri.h" |
|
41 #include "sipstrings.h" |
|
42 #include "sipstrconsts.h" |
|
43 |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CSIPClientConnection::NewL |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CSIPClientConnection* |
|
50 CSIPClientConnection::NewL (CSIPClient& aClient, |
|
51 MSIPClientConnectionObserver& aObserver, |
|
52 TUint32 aIapId) |
|
53 { |
|
54 CSIPClientConnection* self = |
|
55 CSIPClientConnection::NewLC (aClient,aObserver,aIapId); |
|
56 CleanupStack::Pop (self); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CSIPClientConnection::NewLC |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CSIPClientConnection* |
|
65 CSIPClientConnection::NewLC (CSIPClient& aClient, |
|
66 MSIPClientConnectionObserver& aObserver, |
|
67 TUint32 aIapId) |
|
68 { |
|
69 CSIPClientConnection* self = |
|
70 new(ELeave)CSIPClientConnection(aClient,aObserver,aIapId); |
|
71 CleanupStack::PushL (self); |
|
72 self->ConstructL (); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CSIPClientConnection::CSIPClientConnection |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CSIPClientConnection::CSIPClientConnection ( |
|
81 CSIPClient& aClient, |
|
82 MSIPClientConnectionObserver& aObserver, |
|
83 TUint32 aIapId) |
|
84 : iClient (aClient), |
|
85 iObserver (aObserver), |
|
86 iIapId (aIapId), |
|
87 iAdded (EFalse) |
|
88 { |
|
89 iTag = SIPStrings::StringF(SipStrConsts::ETag); |
|
90 iContactHeaderName = SIPStrings::StringF(SipStrConsts::EContactHeader); |
|
91 iExpiresHeaderName = SIPStrings::StringF(SipStrConsts::EExpiresHeader); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CSIPClientConnection::ConstructL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CSIPClientConnection::ConstructL () |
|
99 { |
|
100 iConnection = new(ELeave)RSIPConnection(iIapId); |
|
101 TInt err = iConnection->Open(iClient.SIP()); |
|
102 if (err != KErrNone) |
|
103 { |
|
104 User::Leave(err); |
|
105 } |
|
106 iSender = CSIPITCSender::NewL(*iConnection); |
|
107 iReceiver = new(ELeave)CSIPClientConnectionReceiver(*iConnection,iObserver); |
|
108 iClient.AddL(this); |
|
109 iAdded = ETrue; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CSIPClientConnection::~CSIPClientConnection |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 CSIPClientConnection::~CSIPClientConnection() |
|
117 { |
|
118 if (iAdded) |
|
119 { |
|
120 iClient.Remove(this); |
|
121 } |
|
122 delete iSender; |
|
123 delete iReceiver; |
|
124 if (iConnection) |
|
125 { |
|
126 iConnection->Close(); |
|
127 } |
|
128 delete iConnection; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CSIPClientConnection::State |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 CSIPConnection::TState CSIPClientConnection::State () const |
|
136 { |
|
137 return iConnection->State(); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CSIPClientConnection::IapId |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 TUint32 CSIPClientConnection::IapId () const |
|
145 { |
|
146 return iIapId; |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CSIPClientConnection::GetLocalAddrL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CSIPClientConnection::GetLocalAddrL(TInetAddr& aAddr) const |
|
154 { |
|
155 TPckgBuf<TInetAddr> addrBuf; |
|
156 TIpcArgs args(TIpcArgs::ENothing); |
|
157 args.Set(ESipItcArgLocalAddr, &addrBuf); |
|
158 // SIP ids always required by the SIP server |
|
159 TSIPIds dummyIds; |
|
160 TPckgBuf<TSIPIds> dummySipIdsPckg(dummyIds); |
|
161 args.Set(ESipItcArgIds, &dummySipIdsPckg); |
|
162 TInt err = iConnection->Send(ESipItcGetLocalAddr,args); |
|
163 if (err != KErrNone) |
|
164 { |
|
165 User::Leave(err); |
|
166 } |
|
167 aAddr = addrBuf(); |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CSIPClientConnection::SetOptL |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CSIPClientConnection::SetOptL (TUint aOptionName, |
|
175 TUint aOptionLevel, |
|
176 const TDesC8& aOption) |
|
177 { |
|
178 TPckgBuf<TSIPSockOpt> opt(TSIPSockOpt(aOptionName,aOptionLevel)); |
|
179 TIpcArgs args(TIpcArgs::ENothing); |
|
180 args.Set(ESipItcArgSockOpt, &opt); |
|
181 args.Set(ESipItcArgSockOptDes, &aOption); |
|
182 // SIP ids always required by the SIP server |
|
183 TSIPIds dummyIds; |
|
184 TPckgBuf<TSIPIds> dummySipIdsPckg(dummyIds); |
|
185 args.Set(ESipItcArgIds, &dummySipIdsPckg); |
|
186 TInt err = iConnection->Send(ESipItcSetSIPSockOptWithDes,args); |
|
187 if (err != KErrNone) |
|
188 { |
|
189 User::Leave(err); |
|
190 } |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CSIPClientConnection::SetOptL |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CSIPClientConnection::SetOptL (TUint aOptionName, |
|
198 TUint aOptionLevel, |
|
199 TInt aOption) |
|
200 { |
|
201 TPckgBuf<TSIPSockOpt> opt(TSIPSockOpt(aOptionName,aOptionLevel,aOption)); |
|
202 TIpcArgs args(TIpcArgs::ENothing); |
|
203 args.Set(ESipItcArgSockOpt, &opt); |
|
204 // SIP ids always required by the SIP server |
|
205 TSIPIds dummyIds; |
|
206 TPckgBuf<TSIPIds> dummySipIdsPckg(dummyIds); |
|
207 args.Set(ESipItcArgIds, &dummySipIdsPckg); |
|
208 TInt err = iConnection->Send(ESipItcSetSIPSockOpt,args); |
|
209 if (err != KErrNone) |
|
210 { |
|
211 User::Leave(err); |
|
212 } |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CSIPClientConnection::SetOutboundProxyL |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 void |
|
220 CSIPClientConnection::SetOutboundProxyL (TUint32 aRegistrationId, |
|
221 const CSIPRouteHeader& aOutboundProxy) |
|
222 { |
|
223 __ASSERT_ALWAYS (aRegistrationId > 0, User::Leave(KErrArgument)); |
|
224 |
|
225 TSIPIds ids; |
|
226 ids.iRegistrationId = aRegistrationId; |
|
227 iSender->SetOutboundProxyL(ids,aOutboundProxy); |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CSIPClientConnection::RemoveOutboundProxy |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 TInt CSIPClientConnection::RemoveOutboundProxy (TUint32 aRegistrationId) |
|
235 { |
|
236 if (!aRegistrationId) |
|
237 { |
|
238 return KErrArgument; |
|
239 } |
|
240 TSIPIds ids; |
|
241 ids.iRegistrationId = aRegistrationId; |
|
242 return iSender->Send(ids,ESipItcRemoveOutboundProxy); |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------------------------- |
|
246 // CSIPClientConnection::OutboundProxyL |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 CSIPRouteHeader* CSIPClientConnection::OutboundProxyL (TUint32 aRegistrationId) |
|
250 { |
|
251 __ASSERT_ALWAYS (aRegistrationId > 0, User::Leave(KErrArgument)); |
|
252 |
|
253 TSIPIds ids; |
|
254 ids.iRegistrationId = aRegistrationId; |
|
255 return static_cast<CSIPRouteHeader*>( |
|
256 iSender->ReadSIPHeaderL(ids,ESipItcOutboundProxy, |
|
257 SIPStrings::StringF(SipStrConsts::ERouteHeader))); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CSIPClientConnection::AorL |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 CSIPFromHeader* CSIPClientConnection::AorL (TUint32 aRegistrationId) |
|
265 { |
|
266 __ASSERT_ALWAYS (aRegistrationId > 0, User::Leave(KErrArgument)); |
|
267 |
|
268 TSIPIds ids; |
|
269 ids.iRegistrationId = aRegistrationId; |
|
270 return static_cast<CSIPFromHeader*>( |
|
271 iSender->ReadSIPHeaderL(ids,ESipItcGetFromHeader, |
|
272 SIPStrings::StringF(SipStrConsts::EFromHeader))); |
|
273 } |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CSIPClientConnection::SendRegisterL |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 void CSIPClientConnection::SendRegisterL (TUint32& aRequestId, |
|
280 const CSIPToHeader& aTo, |
|
281 const CSIPFromHeader& aFrom, |
|
282 const CSIPMessageElements& aElements, |
|
283 const CUri8* aRemoteUri, |
|
284 const CSIPRouteHeader* aProxy, |
|
285 TBool aRefresh, |
|
286 TBool aSendWithExpires, |
|
287 TBool aCacheOutboundProxyIP) |
|
288 { |
|
289 __ASSERT_ALWAYS (!aTo.HasParam(iTag), User::Leave(KErrArgument)); |
|
290 __ASSERT_ALWAYS (!aFrom.HasParam(iTag), User::Leave(KErrArgument)); |
|
291 |
|
292 CheckContactExpiresL(aElements); |
|
293 if (aElements.UserHeaderCount(iExpiresHeaderName) > 0) |
|
294 { |
|
295 CheckExpiresHeaderL(aElements); |
|
296 } |
|
297 TSipItcFunctions func; |
|
298 TSIPIds ids; |
|
299 ids.iRefresh = aRefresh; |
|
300 ids.iSendWithExpires = aSendWithExpires; |
|
301 ids.iCacheOutboundProxyIP = aCacheOutboundProxyIP; |
|
302 if (aProxy) |
|
303 { |
|
304 func = ESipItcRegisterAndSetOutboundProxy; |
|
305 } |
|
306 else |
|
307 { |
|
308 func = ESipItcRegister; |
|
309 } |
|
310 iSender->SendL(ids,func,SIPStrings::StringF(SipStrConsts::EEmpty), |
|
311 aRemoteUri,&aFrom,&aTo,&aElements,aProxy); |
|
312 aRequestId = ids.iRequestId; |
|
313 } |
|
314 |
|
315 // ----------------------------------------------------------------------------- |
|
316 // CSIPClientConnection::UpdateRegistrationL |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 void |
|
320 CSIPClientConnection::UpdateRegistrationL (TUint32 aRegistrationId, |
|
321 TUint32& aNewRequestId, |
|
322 const CSIPMessageElements* aElements) |
|
323 { |
|
324 __ASSERT_ALWAYS (aRegistrationId > 0, User::Leave(KErrArgument)); |
|
325 if (aElements && aElements->UserHeaderCount(iContactHeaderName) > 0) |
|
326 { |
|
327 CheckContactExpiresL(*aElements); |
|
328 } |
|
329 if (aElements && aElements->UserHeaderCount(iExpiresHeaderName) > 0) |
|
330 { |
|
331 CheckExpiresHeaderL(*aElements); |
|
332 } |
|
333 |
|
334 TSIPIds ids; |
|
335 ids.iRegistrationId = aRegistrationId; |
|
336 iSender->SendL(ids,ESipItcUpdateRegistration,aElements); |
|
337 aNewRequestId = ids.iRequestId; |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CSIPClientConnection::UnregisterL |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 void CSIPClientConnection::UnregisterL (TUint32 aRegistrationId, |
|
345 TUint32& aNewRequestId, |
|
346 const CSIPMessageElements* aElements) |
|
347 { |
|
348 __ASSERT_ALWAYS (aRegistrationId > 0, User::Leave(KErrArgument)); |
|
349 if (aElements != 0) |
|
350 { |
|
351 __ASSERT_ALWAYS (aElements->UserHeaderCount(iContactHeaderName) == 0, |
|
352 User::Leave(KErrArgument)); |
|
353 __ASSERT_ALWAYS (aElements->UserHeaderCount(iExpiresHeaderName) == 0, |
|
354 User::Leave(KErrArgument)); |
|
355 } |
|
356 TSIPIds ids; |
|
357 ids.iRegistrationId = aRegistrationId; |
|
358 iSender->SendL(ids,ESipItcUnRegister,aElements); |
|
359 aNewRequestId = ids.iRequestId; |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CSIPClientConnection::FetchRegistrationsL |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 void |
|
367 CSIPClientConnection::FetchRegistrationsL (const CSIPRequestElements& aElements, |
|
368 TUint32& aRequestId) |
|
369 { |
|
370 __ASSERT_ALWAYS (aElements.Method().DesC().Length()==0, |
|
371 User::Leave(KErrArgument)); |
|
372 __ASSERT_ALWAYS (aElements.FromHeader() != 0, User::Leave(KErrArgument)); |
|
373 __ASSERT_ALWAYS ( |
|
374 aElements.MessageElements().UserHeaderCount(iContactHeaderName) == 0, |
|
375 User::Leave(KErrArgument)); |
|
376 __ASSERT_ALWAYS ( |
|
377 aElements.MessageElements().UserHeaderCount(iExpiresHeaderName) == 0, |
|
378 User::Leave(KErrArgument)); |
|
379 |
|
380 TSIPIds ids; |
|
381 iSender->SendL(ids,ESipItcFetchRegistrations,aElements); |
|
382 aRequestId = ids.iRequestId; |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CSIPClientConnection::SendRequestL |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 void CSIPClientConnection::SendRequestL (const CSIPRequestElements& aElements, |
|
390 TUint32& aRequestId, |
|
391 TUint32 aRegistrationId, |
|
392 TBool aRefresh) |
|
393 { |
|
394 __ASSERT_ALWAYS (aElements.Method().DesC().Length() > 0, |
|
395 User::Leave(KErrArgument)); |
|
396 if (aRefresh) |
|
397 { |
|
398 CheckExpiresHeaderL(aElements.MessageElements()); |
|
399 } |
|
400 TSIPIds ids; |
|
401 ids.iRegistrationId = aRegistrationId; |
|
402 if (!aRegistrationId) |
|
403 { |
|
404 __ASSERT_ALWAYS(aElements.FromHeader()!=0, User::Leave(KErrArgument)); |
|
405 } |
|
406 ids.iRefresh = aRefresh; |
|
407 iSender->SendL(ids,ESipItcSendRequest,aElements); |
|
408 aRequestId = ids.iRequestId; |
|
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // CSIPClientConnection::SendRequestAndUpdateRefreshL |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 void CSIPClientConnection::SendRequestAndUpdateRefreshL ( |
|
416 TUint32 aRefreshId, |
|
417 TUint32& aNewRequestId, |
|
418 const CSIPMessageElements* aElements) |
|
419 { |
|
420 __ASSERT_ALWAYS (aRefreshId > 0, User::Leave(KErrArgument)); |
|
421 |
|
422 TSIPIds ids; |
|
423 ids.iRefreshId = aRefreshId; |
|
424 iSender->SendL(ids,ESipItcSendRequestAndUpdateRefresh,aElements); |
|
425 aNewRequestId = ids.iRequestId; |
|
426 } |
|
427 |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CSIPClientConnection::SendRequestAndTerminateRefreshL |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 void CSIPClientConnection::SendRequestAndTerminateRefreshL ( |
|
434 TUint32 aRefreshId, |
|
435 TUint32& aNewRequestId, |
|
436 const CSIPMessageElements* aElements) |
|
437 { |
|
438 __ASSERT_ALWAYS (aRefreshId > 0, User::Leave(KErrArgument)); |
|
439 |
|
440 if (aElements) |
|
441 { |
|
442 RPointerArray<CSIPHeaderBase> expireHeaders = |
|
443 aElements->UserHeadersL(iExpiresHeaderName); |
|
444 CleanupClosePushL(expireHeaders); |
|
445 if (expireHeaders.Count() == 1) |
|
446 { |
|
447 CSIPExpiresHeader* expires = |
|
448 static_cast<CSIPExpiresHeader*>(expireHeaders[0]); |
|
449 __ASSERT_ALWAYS (expires->Value()==0, User::Leave(KErrArgument)); |
|
450 } |
|
451 CleanupStack::PopAndDestroy(1); // expireHeaders |
|
452 } |
|
453 |
|
454 TSIPIds ids; |
|
455 ids.iRefreshId = aRefreshId; |
|
456 iSender->SendL(ids,ESipItcSendRequestAndTerminateRefresh,aElements); |
|
457 aNewRequestId = ids.iRequestId; |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CSIPClientConnection::SendResponseL |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 void CSIPClientConnection::SendResponseL (const CSIPResponseElements& aElements, |
|
465 TUint32 aRequestId) |
|
466 { |
|
467 __ASSERT_ALWAYS (aRequestId > 0, User::Leave(KErrArgument)); |
|
468 |
|
469 TSIPIds ids; |
|
470 ids.iRequestId = aRequestId; |
|
471 iSender->SendL(ids,ESipItcSendResponse,aElements); |
|
472 } |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // CSIPClientConnection::SendAckL |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 void CSIPClientConnection::SendAckL (TUint32 aDialogId, |
|
479 TUint32 aRequestId, |
|
480 const CSIPMessageElements* aElements) |
|
481 { |
|
482 __ASSERT_ALWAYS (aRequestId > 0, User::Leave(KErrArgument)); |
|
483 __ASSERT_ALWAYS (aDialogId > 0, User::Leave(KErrArgument)); |
|
484 |
|
485 TSIPIds ids; |
|
486 ids.iDialogId = aDialogId; |
|
487 ids.iRequestId = aRequestId; |
|
488 iSender->SendL(ids,ESipItcSendRequestInDialog, |
|
489 SIPStrings::StringF(SipStrConsts::EAck),aElements); |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CSIPClientConnection::SendCancelL |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 void CSIPClientConnection::SendCancelL (TUint32 aInviteRequestId, |
|
497 TUint32& aCancelRequestId) |
|
498 { |
|
499 __ASSERT_ALWAYS (aInviteRequestId > 0, User::Leave(KErrArgument)); |
|
500 |
|
501 TSIPIds ids; |
|
502 ids.iRequestId = aInviteRequestId; |
|
503 iSender->SendL(ids,ESipItcSendCancel); |
|
504 aCancelRequestId = ids.iRequestId; |
|
505 } |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // CSIPClientConnection::SendResponseAndCreateDialogL |
|
509 // ----------------------------------------------------------------------------- |
|
510 // |
|
511 void CSIPClientConnection::SendResponseAndCreateDialogL ( |
|
512 const CSIPResponseElements& aElements, |
|
513 TUint32 aRequestId, |
|
514 TUint32& aDialogId, |
|
515 TUint32 aRegistrationId) |
|
516 { |
|
517 __ASSERT_ALWAYS (aRequestId > 0, User::Leave(KErrArgument)); |
|
518 |
|
519 CheckContactL(aElements.MessageElements()); |
|
520 |
|
521 TSIPIds ids; |
|
522 ids.iRequestId = aRequestId; |
|
523 ids.iRegistrationId = aRegistrationId; |
|
524 iSender->SendL(ids,ESipItcSendResponseAndCreateDialog,aElements); |
|
525 aDialogId= ids.iDialogId; |
|
526 } |
|
527 |
|
528 // ----------------------------------------------------------------------------- |
|
529 // CSIPClientConnection::SendResponseWithinDialogL |
|
530 // ----------------------------------------------------------------------------- |
|
531 // |
|
532 void CSIPClientConnection::SendResponseWithinDialogL ( |
|
533 const CSIPResponseElements& aElements, |
|
534 TUint32 aRequestId, |
|
535 TUint32 aDialogId, |
|
536 TBool aTargetRefresh) |
|
537 { |
|
538 __ASSERT_ALWAYS (aRequestId > 0, User::Leave(KErrArgument)); |
|
539 __ASSERT_ALWAYS (aDialogId > 0, User::Leave(KErrArgument)); |
|
540 |
|
541 TSIPIds ids; |
|
542 ids.iRequestId = aRequestId; |
|
543 ids.iDialogId = aDialogId; |
|
544 ids.iTargetRefresh = aTargetRefresh; |
|
545 if (aTargetRefresh) |
|
546 { |
|
547 CheckContactL(aElements.MessageElements()); |
|
548 } |
|
549 iSender->SendL(ids,ESipItcSendResponseInDialog,aElements); |
|
550 } |
|
551 |
|
552 // ----------------------------------------------------------------------------- |
|
553 // CSIPClientConnection::SendRequestAndCreateDialogL |
|
554 // ----------------------------------------------------------------------------- |
|
555 // |
|
556 void CSIPClientConnection::SendRequestAndCreateDialogL ( |
|
557 TUint32& aRequestId, |
|
558 TUint32& aRefreshId, |
|
559 TUint32& aDialogId, |
|
560 RStringF aMethod, |
|
561 const CUri8& aRemoteUri, |
|
562 const CSIPFromHeader* aFrom, |
|
563 const CSIPMessageElements* aElements, |
|
564 const CSIPToHeader* aTo, |
|
565 TUint32 aRegistrationId, |
|
566 TBool aRefresh) |
|
567 { |
|
568 __ASSERT_ALWAYS (aMethod.DesC().Length() > 0,User::Leave(KErrArgument)); |
|
569 CheckDialogCreationRequestL (aTo,aFrom,aElements,aRegistrationId,aRefresh); |
|
570 TSIPIds ids; |
|
571 ids.iDialogId = aDialogId; |
|
572 ids.iRegistrationId = aRegistrationId; |
|
573 TSipItcFunctions func = ESipItcSendRequestAndCreateDialog; |
|
574 ids.iRefresh = aRefresh; |
|
575 iSender->SendL(ids,func,aMethod,&aRemoteUri,aFrom,aTo,aElements); |
|
576 aRequestId = ids.iRequestId; |
|
577 aRefreshId = ids.iRefreshId; |
|
578 aDialogId= ids.iDialogId; |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CSIPClientConnection::SendRequestWithinDialogL |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 void CSIPClientConnection::SendRequestWithinDialogL ( |
|
586 TUint32 aDialogId, |
|
587 TUint32& aNewRequestId, |
|
588 TUint32& aRefreshId, |
|
589 RStringF aMethod, |
|
590 const CSIPMessageElements* aElements, |
|
591 TBool aTargetRefresh, |
|
592 TBool aRefresh) |
|
593 { |
|
594 __ASSERT_ALWAYS (aDialogId > 0, User::Leave(KErrArgument)); |
|
595 __ASSERT_ALWAYS (aMethod.DesC().Length() > 0, User::Leave(KErrArgument)); |
|
596 __ASSERT_ALWAYS (aMethod != SIPStrings::StringF(SipStrConsts::ERegister), |
|
597 User::Leave(KErrArgument)); |
|
598 __ASSERT_ALWAYS (aMethod != SIPStrings::StringF(SipStrConsts::ECancel), |
|
599 User::Leave(KErrArgument)); |
|
600 __ASSERT_ALWAYS (aMethod != SIPStrings::StringF(SipStrConsts::EAck), |
|
601 User::Leave(KErrArgument)); |
|
602 if (aTargetRefresh) |
|
603 { |
|
604 CheckContactL(aElements); |
|
605 } |
|
606 TSIPIds ids; |
|
607 ids.iDialogId = aDialogId; |
|
608 ids.iTargetRefresh = aTargetRefresh; |
|
609 ids.iRefresh = aRefresh; |
|
610 if (aRefresh) |
|
611 { |
|
612 __ASSERT_ALWAYS(aMethod != SIPStrings::StringF(SipStrConsts::EMessage), |
|
613 User::Leave(KErrArgument)); |
|
614 CheckExpiresHeaderL(aElements); |
|
615 } |
|
616 iSender->SendL(ids,ESipItcSendRequestInDialog,aMethod,aElements); |
|
617 aNewRequestId = ids.iRequestId; |
|
618 aRefreshId = ids.iRefreshId; |
|
619 } |
|
620 |
|
621 // ----------------------------------------------------------------------------- |
|
622 // CSIPClientConnection::SendRequestWithinDialogL |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 void CSIPClientConnection::SendRequestWithinDialogL ( |
|
626 TUint32 aDialogId, |
|
627 TUint32 aRefreshId, |
|
628 TUint32& aNewRequestId, |
|
629 const CSIPMessageElements* aElements) |
|
630 { |
|
631 __ASSERT_ALWAYS (aDialogId > 0, User::Leave(KErrArgument)); |
|
632 __ASSERT_ALWAYS (aRefreshId > 0, User::Leave(KErrArgument)); |
|
633 CheckContactL(aElements); |
|
634 CheckExpiresHeaderL(aElements,ETrue); |
|
635 |
|
636 TSIPIds ids; |
|
637 ids.iDialogId = aDialogId; |
|
638 ids.iRefreshId = aRefreshId; |
|
639 iSender->SendL(ids,ESipItcSendRequestInDialogAndUpdateRefresh,aElements); |
|
640 aNewRequestId = ids.iRequestId; |
|
641 } |
|
642 |
|
643 // ----------------------------------------------------------------------------- |
|
644 // CSIPClientConnection::CallIDL |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 CSIPCallIDHeader* CSIPClientConnection::CallIDL (TUint32 aDialogId) |
|
648 { |
|
649 __ASSERT_ALWAYS (aDialogId > 0, User::Leave(KErrArgument)); |
|
650 |
|
651 TSIPIds ids; |
|
652 ids.iDialogId = aDialogId; |
|
653 return iSender->ReadCallIDHeaderL(ids); |
|
654 } |
|
655 |
|
656 // ----------------------------------------------------------------------------- |
|
657 // CSIPClientConnection::LocalTagL |
|
658 // ----------------------------------------------------------------------------- |
|
659 // |
|
660 RStringF CSIPClientConnection::LocalTagL (TUint32 aDialogId) |
|
661 { |
|
662 __ASSERT_ALWAYS (aDialogId > 0, User::Leave(KErrArgument)); |
|
663 |
|
664 TSIPIds ids; |
|
665 ids.iDialogId = aDialogId; |
|
666 return iSender->ReadLocalTagL(ids); |
|
667 } |
|
668 |
|
669 // ----------------------------------------------------------------------------- |
|
670 // CSIPClientConnection::ContactL |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 CSIPContactHeader* CSIPClientConnection::ContactL (TUint32 aRegistrationId) |
|
674 { |
|
675 __ASSERT_ALWAYS (aRegistrationId > 0, User::Leave(KErrArgument)); |
|
676 |
|
677 TSIPIds ids; |
|
678 ids.iRegistrationId = aRegistrationId; |
|
679 return static_cast<CSIPContactHeader*>( |
|
680 iSender->ReadSIPHeaderL(ids,ESipItcGetRegisteredContact, |
|
681 SIPStrings::StringF(SipStrConsts::EContactHeader))); |
|
682 } |
|
683 |
|
684 // ----------------------------------------------------------------------------- |
|
685 // CSIPClientConnection::TerminateDialog |
|
686 // ----------------------------------------------------------------------------- |
|
687 // |
|
688 TInt CSIPClientConnection::TerminateDialog (TUint32 aDialogId) |
|
689 { |
|
690 if (!aDialogId) |
|
691 { |
|
692 return KErrArgument; |
|
693 } |
|
694 TSIPIds ids; |
|
695 ids.iDialogId = aDialogId; |
|
696 return iSender->Send(ids,ESipItcTerminateDialog); |
|
697 } |
|
698 |
|
699 // ----------------------------------------------------------------------------- |
|
700 // CSIPClientConnection::TerminateRefresh |
|
701 // ----------------------------------------------------------------------------- |
|
702 // |
|
703 TInt CSIPClientConnection::TerminateRefresh (TUint32 aRefreshId) |
|
704 { |
|
705 if (!aRefreshId) |
|
706 { |
|
707 return KErrArgument; |
|
708 } |
|
709 TSIPIds ids; |
|
710 ids.iRefreshId = aRefreshId; |
|
711 return iSender->Send(ids,ESipItcTerminateRefresh); |
|
712 } |
|
713 |
|
714 // ----------------------------------------------------------------------------- |
|
715 // CSIPClientConnection::SetRefreshIntervalL |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 void CSIPClientConnection::SetRefreshIntervalL (TUint32 aRefreshId, |
|
719 TUint aInterval) |
|
720 { |
|
721 __ASSERT_ALWAYS (aRefreshId > 0, User::Leave(KErrArgument)); |
|
722 __ASSERT_ALWAYS (aInterval > 0, User::Leave(KErrArgument)); |
|
723 __ASSERT_ALWAYS (aInterval <= KMaxTInt, User::Leave(KErrArgument)); |
|
724 TSIPIds ids; |
|
725 ids.iRefreshId = aRefreshId; |
|
726 iSender->SetRefreshIntervalL(ids,aInterval); |
|
727 } |
|
728 |
|
729 // ----------------------------------------------------------------------------- |
|
730 // CSIPClientConnection::RefreshIntervalL |
|
731 // ----------------------------------------------------------------------------- |
|
732 // |
|
733 TUint CSIPClientConnection::RefreshIntervalL (TUint32 aRefreshId) |
|
734 { |
|
735 __ASSERT_ALWAYS (aRefreshId > 0, User::Leave(KErrArgument)); |
|
736 TSIPIds ids; |
|
737 ids.iRefreshId = aRefreshId; |
|
738 TInt interval = 0; |
|
739 iSender->GetRefreshIntervalL(ids, interval); |
|
740 __ASSERT_ALWAYS (interval >= 0, User::Leave(KErrUnderflow)); |
|
741 return interval; |
|
742 } |
|
743 |
|
744 // ----------------------------------------------------------------------------- |
|
745 // CSIPClientConnection::TerminateDialogRefresh |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 TInt CSIPClientConnection::TerminateDialogRefresh (TUint32 aDialogId, |
|
749 TUint32 aRefreshId) |
|
750 { |
|
751 if (!aDialogId || !aRefreshId) |
|
752 { |
|
753 return KErrArgument; |
|
754 } |
|
755 TSIPIds ids; |
|
756 ids.iDialogId = aDialogId; |
|
757 ids.iRefreshId = aRefreshId; |
|
758 return iSender->Send(ids,ESipItcTerminateDialogRefresh); |
|
759 } |
|
760 |
|
761 // ----------------------------------------------------------------------------- |
|
762 // CSIPClientConnection::TerminateRegistration |
|
763 // ----------------------------------------------------------------------------- |
|
764 // |
|
765 TInt CSIPClientConnection::TerminateRegistration (TUint32 aId) |
|
766 { |
|
767 if (!aId) |
|
768 { |
|
769 return KErrArgument; |
|
770 } |
|
771 TSIPIds ids; |
|
772 ids.iRegistrationId = aId; |
|
773 return iSender->Send(ids,ESipItcTerminateRegistration); |
|
774 } |
|
775 |
|
776 // ----------------------------------------------------------------------------- |
|
777 // CSIPClientConnection::ResetDialogState |
|
778 // ----------------------------------------------------------------------------- |
|
779 // |
|
780 TInt CSIPClientConnection::ResetDialogState (TUint32 aDialogId) |
|
781 { |
|
782 if (!aDialogId) |
|
783 { |
|
784 return KErrArgument; |
|
785 } |
|
786 TSIPIds ids; |
|
787 ids.iDialogId = aDialogId; |
|
788 return iSender->Send(ids,ESipItcResetDialogState); |
|
789 } |
|
790 |
|
791 // ----------------------------------------------------------------------------- |
|
792 // CSIPClientConnection::DetachClient |
|
793 // ----------------------------------------------------------------------------- |
|
794 // |
|
795 void CSIPClientConnection::DetachClient() |
|
796 { |
|
797 iAdded = EFalse; |
|
798 } |
|
799 |
|
800 // ----------------------------------------------------------------------------- |
|
801 // CSIPClientConnection::CheckDialogCreationRequestL |
|
802 // ----------------------------------------------------------------------------- |
|
803 // |
|
804 void CSIPClientConnection::CheckDialogCreationRequestL ( |
|
805 const CSIPToHeader* aTo, |
|
806 const CSIPFromHeader* aFrom, |
|
807 const CSIPMessageElements* aElements, |
|
808 TUint32 aRegistrationId, |
|
809 TBool aRefresh) |
|
810 { |
|
811 if (aTo) |
|
812 { |
|
813 __ASSERT_ALWAYS (!aTo->HasParam(iTag), User::Leave(KErrArgument)); |
|
814 } |
|
815 CheckContactL(aElements); |
|
816 if (!aRegistrationId) |
|
817 { |
|
818 __ASSERT_ALWAYS(aFrom!=0,User::Leave(KErrArgument)); |
|
819 } |
|
820 if (aRefresh) |
|
821 { |
|
822 CheckExpiresHeaderL(aElements); |
|
823 } |
|
824 } |
|
825 |
|
826 // ----------------------------------------------------------------------------- |
|
827 // CSIPClientConnection::CheckContactExpiresL |
|
828 // ----------------------------------------------------------------------------- |
|
829 // |
|
830 void |
|
831 CSIPClientConnection::CheckContactExpiresL ( |
|
832 const CSIPMessageElements& aElements) const |
|
833 { |
|
834 RPointerArray<CSIPHeaderBase> contacts = |
|
835 aElements.UserHeadersL(iContactHeaderName); |
|
836 CleanupClosePushL(contacts); |
|
837 |
|
838 if (contacts.Count() != 1) |
|
839 { |
|
840 User::Leave(KErrArgument); |
|
841 } |
|
842 |
|
843 CSIPContactHeader* contact = static_cast<CSIPContactHeader*>(contacts[0]); |
|
844 if (contact->Star()) |
|
845 { |
|
846 User::Leave(KErrArgument); |
|
847 } |
|
848 |
|
849 if (contact->ExpiresParameter() == 0) |
|
850 { |
|
851 User::Leave(KErrArgument); |
|
852 } |
|
853 |
|
854 CleanupStack::PopAndDestroy(1); // contacts |
|
855 } |
|
856 |
|
857 // ----------------------------------------------------------------------------- |
|
858 // CSIPClientConnection::CheckContactL |
|
859 // ----------------------------------------------------------------------------- |
|
860 // |
|
861 void |
|
862 CSIPClientConnection::CheckContactL (const CSIPMessageElements* aElements) const |
|
863 { |
|
864 if (aElements != 0) |
|
865 { |
|
866 CheckContactL(*aElements); |
|
867 } |
|
868 } |
|
869 |
|
870 // ----------------------------------------------------------------------------- |
|
871 // CSIPClientConnection::CheckContactL |
|
872 // ----------------------------------------------------------------------------- |
|
873 // |
|
874 void |
|
875 CSIPClientConnection::CheckContactL (const CSIPMessageElements& aElements) const |
|
876 { |
|
877 RPointerArray<CSIPHeaderBase> contacts = |
|
878 aElements.UserHeadersL(iContactHeaderName); |
|
879 CleanupClosePushL(contacts); |
|
880 TInt contactCount = contacts.Count(); |
|
881 if (contactCount > 1) |
|
882 { |
|
883 User::Leave(KErrArgument); |
|
884 } |
|
885 if (contactCount==1 && |
|
886 static_cast<CSIPContactHeader*>(contacts[0])->Star()) |
|
887 { |
|
888 User::Leave(KErrArgument); |
|
889 } |
|
890 CleanupStack::PopAndDestroy(1); // contacts |
|
891 } |
|
892 |
|
893 // ----------------------------------------------------------------------------- |
|
894 // CSIPClientConnection::CheckExpiresHeaderL |
|
895 // ----------------------------------------------------------------------------- |
|
896 // |
|
897 void |
|
898 CSIPClientConnection::CheckExpiresHeaderL (const CSIPMessageElements* aElements, |
|
899 TBool aZeroAllowed) const |
|
900 { |
|
901 if (aElements == 0) |
|
902 { |
|
903 User::Leave(KErrArgument); |
|
904 } |
|
905 CheckExpiresHeaderL (*aElements,aZeroAllowed); |
|
906 } |
|
907 |
|
908 // ----------------------------------------------------------------------------- |
|
909 // CSIPClientConnection::CheckExpiresHeaderL |
|
910 // ----------------------------------------------------------------------------- |
|
911 // |
|
912 void |
|
913 CSIPClientConnection::CheckExpiresHeaderL (const CSIPMessageElements& aElements, |
|
914 TBool aZeroAllowed) const |
|
915 { |
|
916 RPointerArray<CSIPHeaderBase> expireHeaders = |
|
917 aElements.UserHeadersL(iExpiresHeaderName); |
|
918 CleanupClosePushL(expireHeaders); |
|
919 if (expireHeaders.Count() != 1) |
|
920 { |
|
921 User::Leave(KErrArgument); |
|
922 } |
|
923 if (!aZeroAllowed && |
|
924 static_cast<const CSIPExpiresHeader*>(expireHeaders[0])->Value() == 0) |
|
925 { |
|
926 User::Leave(KErrArgument); |
|
927 } |
|
928 CleanupStack::PopAndDestroy(1); // expireHeaders |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CSIPClientConnection::RefreshConnection |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 void CSIPClientConnection::RefreshConnection() const |
|
936 { |
|
937 TSIPIds ids; |
|
938 ids.iIapId = iIapId; |
|
939 iSender->Send(ids,ESipItcRefreshConnection); |
|
940 } |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // CSIPClientConnection::ConnectionErrorL |
|
944 // ----------------------------------------------------------------------------- |
|
945 // |
|
946 TInt CSIPClientConnection::ConnectionErrorL() const |
|
947 { |
|
948 TSIPIds ids; |
|
949 ids.iIapId = iIapId; |
|
950 iSender->SendL(ids,ESipItcGetConnectionError); |
|
951 return ids.iConnectionError; |
|
952 } |