|
1 // Copyright (c) 2005-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 : sipimsprofilecontext.cpp |
|
15 // Part of : sip ims agent |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipimsprofilecontext.h" |
|
24 #include "sipprflstatebase.h" |
|
25 #include "sipconcreteprofile.h" |
|
26 #include "sipmanagedprofile.h" |
|
27 #include "sipimsprofileagent.h" |
|
28 #include "sipregistrationbinding.h" |
|
29 #include "sipclienttransaction.h" |
|
30 #include "sipgendefs.h" |
|
31 #include "siprefresh.h" |
|
32 #include "sipmessagebuilder.h" |
|
33 #include "sipaddress.h" |
|
34 #include "siptoheader.h" |
|
35 #include "siprouteheader.h" |
|
36 #include "sipmessageelements.h" |
|
37 #include "sipresponseelements.h" |
|
38 #include "sipsecurityclientheader.h" |
|
39 #include "sipextensionheader.h" |
|
40 #include "sippassociateduriheader.h" |
|
41 #include "sipsupportedheader.h" |
|
42 #include "SipProfileLog.h" |
|
43 #include "sipstrings.h" |
|
44 #include "sipstrconsts.h" |
|
45 #include "siperr.h" |
|
46 #include "sip.h" |
|
47 #include "sipcontactheader.h" |
|
48 #include "CSIPRegEventHandler.h" |
|
49 #include "sipdialogassocbase.h" |
|
50 #include "Sipimsprofilesimrecord.h" |
|
51 #include "sipunsupportedheader.h" |
|
52 #include "sipretryafterheader.h" |
|
53 |
|
54 _LIT8(KSIPIpSec3gpp, "ipsec-3gpp"); |
|
55 _LIT8(KTransportUdpParam, "transport=udp"); |
|
56 _LIT8(KTransportTcpParam, "transport=tcp"); |
|
57 |
|
58 // ============================ MEMBER FUNCTIONS =============================== |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CSIPIMSProfileContext::NewLC |
|
63 // (other items were commented in a header). |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CSIPIMSProfileContext* CSIPIMSProfileContext::NewLC( |
|
67 CSIPNotifyXmlBodyParser& aXMLParser, |
|
68 CSIP& aSIP, |
|
69 CSIPIMSConnectionContext& aConnection, |
|
70 MSIPProfileAgentObserver& aObserver, |
|
71 CSIPPrflStateBase& aInitState, |
|
72 CSIPConcreteProfile& aProfile, |
|
73 CDeltaTimer& aDeltaTimer, |
|
74 CSIPProfileSIMRecord& aSIMRecord, |
|
75 CSipProfileAgentConfigExtension& aConfigExtension) |
|
76 { |
|
77 CSIPIMSProfileContext* self = |
|
78 new(ELeave)CSIPIMSProfileContext(aXMLParser, aSIP, aConnection, |
|
79 aObserver, aInitState, aProfile, aDeltaTimer, aSIMRecord,aConfigExtension); |
|
80 CleanupStack::PushL(self); |
|
81 self->ConstructL(); |
|
82 return self; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CSIPIMSProfileContext::NewL |
|
87 // (other items were commented in a header). |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CSIPIMSProfileContext* CSIPIMSProfileContext::NewL( |
|
91 CSIPNotifyXmlBodyParser& aXMLParser, |
|
92 CSIP& aSIP, |
|
93 CSIPIMSConnectionContext& aConnection, |
|
94 MSIPProfileAgentObserver& aObserver, |
|
95 CSIPPrflStateBase& aInitState, |
|
96 CSIPConcreteProfile& aProfile, |
|
97 CDeltaTimer& aDeltaTimer, |
|
98 CSIPProfileSIMRecord& aSIMRecord, |
|
99 CSipProfileAgentConfigExtension& aConfigExtension) |
|
100 { |
|
101 CSIPIMSProfileContext* self = |
|
102 CSIPIMSProfileContext::NewLC(aXMLParser, aSIP, aConnection, aObserver, |
|
103 aInitState, aProfile, aDeltaTimer, aSIMRecord,aConfigExtension); |
|
104 CleanupStack::Pop(self); |
|
105 return self; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CSIPIMSProfileContext::CSIPIMSProfileContext |
|
110 // (other items were commented in a header). |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 CSIPIMSProfileContext::CSIPIMSProfileContext( |
|
114 CSIPNotifyXmlBodyParser& aXMLParser, |
|
115 CSIP& aSIP, |
|
116 CSIPIMSConnectionContext& aConnection, |
|
117 MSIPProfileAgentObserver& aObserver, |
|
118 CSIPPrflStateBase& aInitState, |
|
119 CSIPConcreteProfile& aProfile, |
|
120 CDeltaTimer& aDeltaTimer, |
|
121 CSIPProfileSIMRecord& aSIMRecord, |
|
122 CSipProfileAgentConfigExtension& aConfigExtension) |
|
123 : CSIPProfileContextBase(aSIP, |
|
124 *(aConnection.Connection()), |
|
125 aObserver, |
|
126 aInitState, |
|
127 aProfile, |
|
128 aDeltaTimer), |
|
129 iXMLParser(aXMLParser), |
|
130 iConnectionContext(aConnection), |
|
131 iSIMRecord(aSIMRecord), |
|
132 iConnectionDropped(EFalse), |
|
133 iDeactivatedByNetwork(EFalse), |
|
134 iRetriedRegister(EFalse), |
|
135 iRetryTimerUse(EFalse), |
|
136 iUseDynamicProxyForTry(EFalse), |
|
137 iConfigExtension(aConfigExtension) |
|
138 { |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CSIPIMSProfileContext::ConstructL() |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CSIPIMSProfileContext::ConstructL() |
|
146 { |
|
147 iPathStr = SIPStrings::Pool().OpenFStringL(KSIPpath()); |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CSIPIMSProfileContext::~CSIPIMSProfileContext |
|
152 // (other items were commented in a header). |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 CSIPIMSProfileContext::~CSIPIMSProfileContext() |
|
156 { |
|
157 delete iRegEventHandler; |
|
158 delete iPAURI; |
|
159 iPathStr.Close(); |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CSIPIMSProfileContext::AgentObserver() |
|
164 // (other items were commented in a header). |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 MSIPProfileAgentObserver& CSIPIMSProfileContext::AgentObserver() const |
|
168 { |
|
169 const MSIPProfileAgentObserver& obs = *this; |
|
170 return const_cast<MSIPProfileAgentObserver&>(obs); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CSIPIMSProfileContext::DestroyRegistration() |
|
175 // (other items were commented in a header). |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CSIPIMSProfileContext::DestroyRegistration() |
|
179 { |
|
180 PROFILE_DEBUG3("SIPIMSProfileContext::DestroyRegistration", ProfileId()) |
|
181 delete iRegistration; |
|
182 iRegistration = NULL; |
|
183 RemoveRegEventHandler(); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CSIPIMSProfileContext::CreateRegistrationL |
|
188 // (other items were commented in a header). |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CSIPIMSProfileContext::CreateRegistrationL() |
|
192 { |
|
193 ASSERT(iProfile); |
|
194 RStringF transport(SIPStrings::StringF(SipStrConsts::EEmpty)); |
|
195 CleanupClosePushL(transport); |
|
196 TUint pops = 0; |
|
197 CSIPRouteHeader* proxy = 0; |
|
198 CUri8* remoteUri = 0; |
|
199 CSIPRefresh* refresh = CSIPRefresh::NewLC(); |
|
200 pops++; |
|
201 CSIPToHeader* to = 0; |
|
202 if (iConfiguredType == CSIPIMSProfileContext::EEarlyIMSType) |
|
203 { |
|
204 to = SIPMessageBuilder::CreateToLC(iSIMRecord.SIMPublicIdentity()); |
|
205 } |
|
206 |
|
207 else if (iConfiguredType == CSIPIMSProfileContext::EIMSReleaseType) |
|
208 { |
|
209 to = SIPMessageBuilder::CreateToLC(iSIMRecord.PublicIdentity()); |
|
210 } |
|
211 else |
|
212 { |
|
213 //CSIPIMSProfileContext::EClientConfiguredType |
|
214 to = SIPMessageBuilder::CreateToLC(iProfile->AOR()); |
|
215 } |
|
216 pops++; |
|
217 |
|
218 const TDesC8& proxyAddr = ProxyAddressL(); |
|
219 |
|
220 if (proxyAddr.Length()) //there's an outbound proxy defined |
|
221 { |
|
222 (iProfile->IsSigCompEnabled())? |
|
223 proxy = SIPMessageBuilder::CreateRouteLC(proxyAddr, ETrue): |
|
224 proxy = SIPMessageBuilder::CreateRouteLC(proxyAddr); |
|
225 pops++; |
|
226 RStringF proxyTransport = TransportProtocol(proxy->SIPAddress().Uri8()); |
|
227 if (proxyTransport.DesC().Length() > 0) |
|
228 { |
|
229 transport = proxyTransport.Copy(); |
|
230 } |
|
231 } |
|
232 if (iConfiguredType == CSIPIMSProfileContext::EClientConfiguredType) |
|
233 { |
|
234 if (iProfile->Server(KSIPRegistrar).Length()) // registrar defined |
|
235 { |
|
236 TUriParser8 parser; |
|
237 User::LeaveIfError(parser.Parse(iProfile->Server(KSIPRegistrar))); |
|
238 remoteUri = CUri8::NewLC(parser); |
|
239 pops++; |
|
240 if (!proxy) |
|
241 { |
|
242 RStringF registrarTransport = TransportProtocol(*remoteUri); |
|
243 if (registrarTransport.DesC().Length() > 0) |
|
244 { |
|
245 transport = registrarTransport.Copy(); |
|
246 } |
|
247 } |
|
248 } |
|
249 } |
|
250 else |
|
251 { |
|
252 HBufC8* temp = NULL; |
|
253 if (iConfiguredType == CSIPIMSProfileContext::EEarlyIMSType) |
|
254 { |
|
255 temp = iSIMRecord.AddSIPPrefixLC( |
|
256 iSIMRecord.SIMHomeNetworkDomainName()); |
|
257 } |
|
258 if (iConfiguredType == CSIPIMSProfileContext::EIMSReleaseType) |
|
259 { |
|
260 temp = iSIMRecord.AddSIPPrefixLC( |
|
261 iSIMRecord.HomeNetworkDomainName()); |
|
262 } |
|
263 if (temp) |
|
264 { |
|
265 TUriParser8 parser; |
|
266 User::LeaveIfError(parser.Parse(*temp)); |
|
267 remoteUri = CUri8::NewL(parser); |
|
268 CleanupStack::PopAndDestroy(temp); |
|
269 CleanupStack::PushL(remoteUri); |
|
270 pops++; |
|
271 } |
|
272 } |
|
273 TBool sigcomp = iProfile->IsSigCompEnabled(); |
|
274 |
|
275 const TDesC8* user = NULL; |
|
276 User::LeaveIfError( |
|
277 iProfile->ExtensionParameter(KSIPContactHeaderUser,user)); |
|
278 |
|
279 CSIPContactHeader* contact = |
|
280 SIPMessageBuilder::CreateContactLC(*user, |
|
281 iConfigExtension.ExpiryValueL(TSIPProfileTypeInfo::EIms, |
|
282 CSipProfileAgentConfigExtension::EProfileRegistrationValue), |
|
283 iProfile->ContactHeaderParams(), |
|
284 transport, sigcomp); |
|
285 pops++; |
|
286 |
|
287 iRegistration = |
|
288 CSIPRegistrationBinding::NewL(*iConnectionContext.Connection(), |
|
289 to, contact, refresh, proxy, remoteUri); |
|
290 CleanupStack::Pop(pops); |
|
291 CleanupStack::PopAndDestroy(1); // transport |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CSIPIMSProfileContext::CreateMsgElementsLC() |
|
296 // (other items were commented in a header). |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 CSIPMessageElements* CSIPIMSProfileContext::CreateMsgElementsLC() |
|
300 { |
|
301 ASSERT(iProfile); |
|
302 CSIPMessageElements* elements = CSIPMessageElements::NewLC(); |
|
303 RPointerArray<CSIPHeaderBase> headers(CreateSIPHeadersL(*iProfile)); |
|
304 CSIPHeaderBase::PushLC(&headers); |
|
305 |
|
306 if(iConfiguredType != CSIPIMSProfileContext::EEarlyIMSType) |
|
307 { |
|
308 CSIPExtensionHeader* authorization= NULL; |
|
309 if(iConfiguredType == CSIPIMSProfileContext::EClientConfiguredType) |
|
310 { |
|
311 authorization= |
|
312 (iProfile->PrivateIdentity().Length()>0)? |
|
313 SIPMessageBuilder::CreateAuthorizationLC( |
|
314 iProfile->Server(KSIPRegistrar), |
|
315 iProfile->ServerParameter(KSIPRegistrar, KSIPDigestRealm), |
|
316 iProfile->PrivateIdentity()) |
|
317 : |
|
318 SIPMessageBuilder::CreateAuthorizationLC( |
|
319 iProfile->Server(KSIPRegistrar), |
|
320 iProfile->ServerParameter(KSIPRegistrar, KSIPDigestRealm), |
|
321 iProfile->ServerParameter(KSIPRegistrar, KSIPDigestUserName)); |
|
322 } |
|
323 else |
|
324 { |
|
325 HBufC8* temp = |
|
326 iSIMRecord.AddSIPPrefixLC(iSIMRecord.HomeNetworkDomainName()); |
|
327 authorization= |
|
328 SIPMessageBuilder::CreateAuthorizationLC( |
|
329 *temp, |
|
330 iSIMRecord.HomeNetworkDomainName(), |
|
331 iSIMRecord.PrivateIdentity()); |
|
332 CleanupStack::Pop(authorization); |
|
333 CleanupStack::PopAndDestroy(temp); |
|
334 CleanupStack::PushL(authorization); |
|
335 } |
|
336 headers.AppendL(authorization); |
|
337 CleanupStack::Pop(authorization); |
|
338 } |
|
339 |
|
340 CSIPSupportedHeader* supported = CSIPSupportedHeader::NewLC(iPathStr); |
|
341 headers.AppendL(supported); |
|
342 CleanupStack::Pop(supported); |
|
343 AddSecurityClientHeaderL(headers,*iProfile); |
|
344 elements->SetUserHeadersL(headers); |
|
345 CleanupStack::PopAndDestroy(&headers); |
|
346 |
|
347 return elements; |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CSIPIMSProfileContext::CreateDeRegisterElementsL() |
|
352 // (other items were commented in a header). |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 CSIPMessageElements* CSIPIMSProfileContext::CreateDeRegisterElementsL() |
|
356 { |
|
357 ASSERT(iProfile); |
|
358 CSIPMessageElements* elements = CSIPMessageElements::NewLC(); |
|
359 RPointerArray<CSIPHeaderBase> headers(CreateSIPHeadersL(*iProfile)); |
|
360 CSIPHeaderBase::PushLC(&headers); |
|
361 |
|
362 if (iConfiguredType == CSIPIMSProfileContext::EClientConfiguredType) |
|
363 { |
|
364 CSIPExtensionHeader* authorization= NULL; |
|
365 if(iProfile->PrivateIdentity().Length()>0) |
|
366 { |
|
367 authorization = SIPMessageBuilder::CreateAuthorizationLC( |
|
368 iProfile->Server(KSIPRegistrar), |
|
369 iProfile->ServerParameter(KSIPRegistrar, KSIPDigestRealm), |
|
370 iProfile->PrivateIdentity()); |
|
371 } |
|
372 else |
|
373 { |
|
374 authorization = SIPMessageBuilder::CreateAuthorizationLC( |
|
375 iProfile->Server(KSIPRegistrar), |
|
376 iProfile->ServerParameter(KSIPRegistrar, KSIPDigestRealm), |
|
377 iProfile->ServerParameter(KSIPRegistrar, KSIPDigestUserName)); |
|
378 } |
|
379 headers.AppendL(authorization); |
|
380 CleanupStack::Pop(authorization); |
|
381 } |
|
382 |
|
383 AddSecurityClientHeaderL(headers,*iProfile); |
|
384 elements->SetUserHeadersL(headers); |
|
385 CleanupStack::PopAndDestroy(&headers); |
|
386 CleanupStack::Pop(elements); |
|
387 |
|
388 return elements; |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // CSIPIMSProfileContext::UpdateContactHeaderParamsL |
|
393 // (other items were commented in a header). |
|
394 // ----------------------------------------------------------------------------- |
|
395 // |
|
396 void CSIPIMSProfileContext::UpdateContactHeaderParamsL( |
|
397 CSIPConcreteProfile& aNewProfile) |
|
398 { |
|
399 ASSERT(iProfile); |
|
400 CSIPContactHeader& contact = Registration()->ContactHeader(); |
|
401 TPtrC8 paramName; |
|
402 TPtrC8 paramValue; |
|
403 |
|
404 for (TInt i = Profile()->ContactHeaderParams().MdcaCount()-1;i >= 0; i--) |
|
405 { |
|
406 TPtrC8 param(Profile()->ContactHeaderParams().MdcaPoint(i)); |
|
407 SIPMessageBuilder::ParseParamL(param,paramName,paramValue); |
|
408 RStringF name = SIPStrings::Pool().OpenFStringL(paramName); |
|
409 CleanupClosePushL(name); |
|
410 contact.DeleteParam(name); |
|
411 CleanupStack::PopAndDestroy();//name |
|
412 } |
|
413 |
|
414 for (TInt i = 0; &(aNewProfile.ContactHeaderParams()) && |
|
415 (i < aNewProfile.ContactHeaderParams().MdcaCount()); i++) |
|
416 { |
|
417 TPtrC8 param(aNewProfile.ContactHeaderParams().MdcaPoint(i)); |
|
418 TBool hasValue = |
|
419 SIPMessageBuilder::ParseParamL(param,paramName,paramValue); |
|
420 RStringF name = SIPStrings::Pool().OpenFStringL(paramName); |
|
421 CleanupClosePushL(name); |
|
422 if (hasValue) |
|
423 { |
|
424 RStringF value = SIPStrings::Pool().OpenFStringL(paramValue); |
|
425 CleanupClosePushL(value); |
|
426 contact.SetParamL(name,value); |
|
427 CleanupStack::PopAndDestroy(); // value |
|
428 } |
|
429 else |
|
430 { |
|
431 contact.SetParamL(name); |
|
432 } |
|
433 CleanupStack::PopAndDestroy(); // name |
|
434 } |
|
435 |
|
436 CSIPMessageElements* elements = CreateMsgElementsForUpdateLC(aNewProfile); |
|
437 SetTransaction(Registration()->UpdateL( |
|
438 iConfigExtension.ExpiryValueL(TSIPProfileTypeInfo::EIms, |
|
439 CSipProfileAgentConfigExtension::EProfileRegistrationValue), |
|
440 elements)); |
|
441 CleanupStack::Pop(elements); |
|
442 } |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // CSIPIMSProfileContext::RegEventSubscriptionActive() |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 void CSIPIMSProfileContext::RegEventSubscriptionActive() |
|
449 { |
|
450 // Reg-event failure notifications after this must not lead to registration |
|
451 // (see CSIPIMSProfileContext::RegEventSubscriptionFailedL) |
|
452 iConnectionDropped = EFalse; |
|
453 iDeactivatedByNetwork = EFalse; |
|
454 if (iProfile && iRegistration) |
|
455 { |
|
456 iObserver.SIPProfileStatusEvent(*iProfile,iRegistration->ContextId()); |
|
457 } |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CSIPIMSProfileContext::ExpirationTimeUpdatedL() |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 void CSIPIMSProfileContext::ExpirationTimeUpdatedL(TInt aExpirationTime) |
|
465 { |
|
466 __ASSERT_ALWAYS(aExpirationTime > 0 , User::Leave(KErrArgument)); |
|
467 __ASSERT_ALWAYS(iRegistration != NULL, User::Leave(KErrNotReady)); |
|
468 |
|
469 CSIPRefresh* refresh = iRegistration->SIPRefresh(); |
|
470 if(refresh) |
|
471 { |
|
472 refresh->SetIntervalL(aExpirationTime); |
|
473 } |
|
474 } |
|
475 |
|
476 // ----------------------------------------------------------------------------- |
|
477 // CSIPIMSProfileContext::ReRegister() |
|
478 // ----------------------------------------------------------------------------- |
|
479 // |
|
480 void CSIPIMSProfileContext::ReRegister() |
|
481 { |
|
482 TBool handled = ETrue; |
|
483 CSIPProfileContextBase::ErrorOccured(KErrTotalLossOfPrecision, |
|
484 *Registration(),handled); |
|
485 } |
|
486 |
|
487 // ----------------------------------------------------------------------------- |
|
488 // CSIPIMSProfileContext::RegistrationDeactivated() |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 void CSIPIMSProfileContext::RegistrationDeactivated() |
|
492 { |
|
493 if (!iDeactivatedByNetwork) |
|
494 { |
|
495 // For the first deactivation indicate with an error |
|
496 // that an initial reqistration must be performed |
|
497 iDeactivatedByNetwork = ETrue; |
|
498 ReRegister(); |
|
499 } |
|
500 else |
|
501 { |
|
502 // If the network deactivates registration twice in a row, |
|
503 // the profile registration fails |
|
504 RegistrationTerminated(); |
|
505 } |
|
506 } |
|
507 |
|
508 // ----------------------------------------------------------------------------- |
|
509 // CSIPIMSProfileContext::RegistrationTerminated() |
|
510 // ----------------------------------------------------------------------------- |
|
511 // |
|
512 void CSIPIMSProfileContext::RegistrationTerminated() |
|
513 { |
|
514 iCurrentState = iInitState; |
|
515 SetRetryPossible(EFalse); |
|
516 // A specific error code for network initiated de-registration |
|
517 iObserver.SIPProfileErrorEvent(*iProfile,KErrDisconnected); |
|
518 } |
|
519 |
|
520 // ----------------------------------------------------------------------------- |
|
521 // CSIPIMSProfileContext::RegEventSubscriptionFailedL() |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 void CSIPIMSProfileContext::RegEventSubscriptionFailedL() |
|
525 { |
|
526 if (iConnectionDropped) |
|
527 { |
|
528 // Perform an initial registration again |
|
529 iConnectionDropped = EFalse; |
|
530 ReRegister(); |
|
531 } |
|
532 else |
|
533 { |
|
534 iRegEventSubscriptionFailed = ETrue; |
|
535 iCurrentState->DeregisterL(*this); |
|
536 RemoveRegEventHandler(); |
|
537 } |
|
538 } |
|
539 |
|
540 // ----------------------------------------------------------------------------- |
|
541 // CSIPIMSProfileContext::SIPProfileStatusEvent |
|
542 // (other items were commented in a header). |
|
543 // ----------------------------------------------------------------------------- |
|
544 // |
|
545 void CSIPIMSProfileContext::SIPProfileStatusEvent( |
|
546 CSIPConcreteProfile& aProfile, |
|
547 TUint32 aContextId) |
|
548 { |
|
549 PROFILE_DEBUG4("CSIPIMSProfileContext::SIPProfileStatusEvent",\ |
|
550 aProfile.Id(), aContextId) |
|
551 if (CurrentState() == MSIPProfileContext::ERegistered) |
|
552 { |
|
553 TRAPD(err, HandleProfileRegisteredEventL()) |
|
554 if (err) |
|
555 { |
|
556 RemoveRegEventHandler(); |
|
557 SIPProfileErrorEvent(aProfile,err); |
|
558 return; |
|
559 } |
|
560 // Defer the notification about the profile state change |
|
561 // until the subscription to reg-event is active. |
|
562 // See CSIPIMSProfileContext::RegEventSubscriptionActive. |
|
563 } |
|
564 else |
|
565 { |
|
566 if (iRegEventSubscriptionFailed && |
|
567 CurrentState() == MSIPProfileContext::EInit) |
|
568 { |
|
569 // Registration state event subscription has failed, |
|
570 // de-REGISTER was sent and |
|
571 // 200 OK for de-REGISTER was just received. |
|
572 // Indicate profile registration status as failed. |
|
573 iRegEventSubscriptionFailed = EFalse; |
|
574 iObserver.SIPProfileErrorEvent(aProfile,KErrGeneral); |
|
575 } |
|
576 else |
|
577 { |
|
578 iObserver.SIPProfileStatusEvent(aProfile,aContextId); |
|
579 } |
|
580 } |
|
581 } |
|
582 |
|
583 // ----------------------------------------------------------------------------- |
|
584 // CSIPIMSProfileContext::SIPProfileErrorEvent |
|
585 // (other items were commented in a header). |
|
586 // ----------------------------------------------------------------------------- |
|
587 // |
|
588 void CSIPIMSProfileContext::SIPProfileErrorEvent( |
|
589 CSIPConcreteProfile& aProfile, |
|
590 TInt aError) |
|
591 { |
|
592 PROFILE_DEBUG4("CSIPIMSProfileContext::ErrorEvent", aProfile.Id(), aError) |
|
593 iObserver.SIPProfileErrorEvent(aProfile,aError); |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // CSIPIMSProfileContext::ProceedRegistration |
|
598 // (other items were commented in a header). |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 TBool CSIPIMSProfileContext::ProceedRegistration( |
|
602 CSIPConcreteProfile& aProfile, |
|
603 TInt aError) |
|
604 { |
|
605 PROFILE_DEBUG3("CSIPIMSProfileContext::ProceedRegistration", aProfile.Id()) |
|
606 return iObserver.ProceedRegistration(aProfile, aError); |
|
607 } |
|
608 |
|
609 // ----------------------------------------------------------------------------- |
|
610 // CSIPIMSProfileContext::GetFailedProfilesL |
|
611 // ----------------------------------------------------------------------------- |
|
612 // |
|
613 void CSIPIMSProfileContext::GetFailedProfilesL( |
|
614 const TSIPProfileTypeInfo& /*aType*/, |
|
615 RPointerArray<CSIPConcreteProfile>& /*aFailedProfiles*/) const |
|
616 { |
|
617 } |
|
618 |
|
619 // ----------------------------------------------------------------------------- |
|
620 // CSIPIMSProfileContext::DeregisterL |
|
621 // (other items were commented in a header). |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 void CSIPIMSProfileContext::DeregisterL() |
|
625 { |
|
626 PROFILE_DEBUG4("CSIPIMSProfileContext::DeregisterL", ProfileId()\ |
|
627 , iCurrentState->Name()) |
|
628 iCurrentState->DeregisterL(*this); |
|
629 RemoveRegEventHandler(); |
|
630 } |
|
631 |
|
632 // ----------------------------------------------------------------------------- |
|
633 // CSIPIMSProfileContext::UpdateL |
|
634 // (other items were commented in a header). |
|
635 // ----------------------------------------------------------------------------- |
|
636 // |
|
637 void CSIPIMSProfileContext::UpdateL( |
|
638 CSIPConcreteProfile& aNewProfile) |
|
639 { |
|
640 PROFILE_DEBUG4("CSIPIMSProfileContext::UpdateL", ProfileId()\ |
|
641 , iCurrentState->Name()) |
|
642 iCurrentState->UpdateL(*this, aNewProfile); |
|
643 } |
|
644 |
|
645 // ----------------------------------------------------------------------------- |
|
646 // CSIPIMSProfileContext::IncomingResponse() |
|
647 // (other items were commented in a header). |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 void CSIPIMSProfileContext::IncomingResponse( |
|
651 CSIPClientTransaction& aTransaction, |
|
652 CSIPRegistrationBinding& aRegistration, |
|
653 TBool& aHandled) |
|
654 { |
|
655 TUint status=0; |
|
656 if (iClientTx && iRegistration && |
|
657 aTransaction==*iClientTx && aRegistration==*iRegistration) |
|
658 { |
|
659 PROFILE_DEBUG3("SIPIMSProfileContext::IncomingResponse", ProfileId()) |
|
660 aHandled = ETrue; |
|
661 TBool retry = EFalse; |
|
662 if (aTransaction.ResponseElements()) |
|
663 { |
|
664 status = aTransaction.ResponseElements()->StatusCode(); |
|
665 retry = RetryRegister( &aTransaction, status); |
|
666 if ( !retry ) |
|
667 { |
|
668 if (status == K420BadExtension && |
|
669 iConfiguredType == CSIPIMSProfileContext::EIMSReleaseType && |
|
670 IsUnsupportedHeaderValue( |
|
671 SIPStrings::StringF(SipStrConsts::ESecAgreeTag))) |
|
672 { |
|
673 TUint32 confValue = 0; |
|
674 TInt result = 0; |
|
675 result = iProfile->ExtensionParameter( KSIPAllowIMSRegistration, |
|
676 confValue ); |
|
677 if (result != KErrNotFound) |
|
678 { |
|
679 if (confValue == 1 ||confValue == 2) |
|
680 { |
|
681 SetRetryPossible(EFalse); |
|
682 } |
|
683 } |
|
684 else |
|
685 { |
|
686 iConfiguredType = CSIPIMSProfileContext::EEarlyIMSType; |
|
687 SetRetryPossible(ETrue); |
|
688 } |
|
689 } |
|
690 else if (RequireProxyResolving()) |
|
691 { |
|
692 if (status >= K200Ok && status < K300MultipleChoices) |
|
693 { |
|
694 delete iProxies; |
|
695 iProxies = NULL; |
|
696 iUseDynamicProxyForTry = ETrue; |
|
697 Received2XXRegisterResponse(); |
|
698 } |
|
699 else |
|
700 { |
|
701 PROFILE_DEBUG1("SIPIMSProfileContext::registration failed") |
|
702 RetryPossible(status); |
|
703 } |
|
704 } |
|
705 else |
|
706 { |
|
707 // Silence PC-Lint |
|
708 } |
|
709 } |
|
710 } |
|
711 |
|
712 if (retry) |
|
713 { |
|
714 iCurrentState->ErrorOccured(*this, status); |
|
715 } |
|
716 else |
|
717 { |
|
718 TRAPD(err, StoreMsgElementsL()) |
|
719 if (err) |
|
720 { |
|
721 CSIPProfileContextBase::ErrorOccured(err,aRegistration,aHandled); |
|
722 } |
|
723 else |
|
724 { |
|
725 iCurrentState->ResponseReceived(*this, aTransaction); |
|
726 } |
|
727 } |
|
728 } |
|
729 } |
|
730 |
|
731 // ----------------------------------------------------------------------------- |
|
732 // CSIPIMSProfileContext::RetryRegister() |
|
733 // ----------------------------------------------------------------------------- |
|
734 // |
|
735 TBool CSIPIMSProfileContext::RetryRegister( |
|
736 CSIPClientTransaction* aTransaction, |
|
737 TInt aError ) |
|
738 { |
|
739 TBool retry = EFalse; |
|
740 if (iProfile && |
|
741 AgentObserver().ProceedRegistration(*iProfile, aError) && |
|
742 (!iRetriedRegister && |
|
743 (CurrentState() == MSIPProfileContext::ERegistrationInProgress || |
|
744 CurrentState() == MSIPProfileContext::ERegistered))) |
|
745 { |
|
746 if ( aError == K503ServiceUnavailable || |
|
747 aError == K408TimeOut || |
|
748 aError == K480TemporarilyUnavailable || |
|
749 aError == K500ServerInternalError || |
|
750 aError == K504ServerTimeOut || |
|
751 aError == KErrTimedOut || |
|
752 aError == KErrSIPOutboundProxyNotResponding || |
|
753 aError == KErrSIPResolvingFailure || |
|
754 aError == KErrSIPTransportFailure || |
|
755 aError == KErrSIPICMPFailure && |
|
756 iConnection.State() != CSIPConnection::ESuspended) |
|
757 { |
|
758 SetRetryPossible(ETrue); |
|
759 iRetriedRegister = ETrue; |
|
760 iRetryCounterSum++; |
|
761 retry = ETrue; |
|
762 if ( aTransaction ) |
|
763 { |
|
764 CheckRetryAfter( aTransaction ); |
|
765 } |
|
766 } |
|
767 } |
|
768 else |
|
769 { |
|
770 SetRetryPossible(EFalse); |
|
771 iRetriedRegister = EFalse; |
|
772 iRetryTimerUse = EFalse; |
|
773 iRetryCounterSum = 0; |
|
774 } |
|
775 return retry; |
|
776 } |
|
777 |
|
778 // ----------------------------------------------------------------------------- |
|
779 // CSIPIMSProfileContext::ShouldRetryRegistration |
|
780 // ----------------------------------------------------------------------------- |
|
781 // |
|
782 TBool CSIPIMSProfileContext::ShouldRetryRegistration( TInt aError ) |
|
783 { |
|
784 return (aError == K503ServiceUnavailable || |
|
785 aError == K408TimeOut || |
|
786 aError == K480TemporarilyUnavailable || |
|
787 aError == K500ServerInternalError || |
|
788 aError == K504ServerTimeOut || |
|
789 aError == KErrSIPOutboundProxyNotResponding || |
|
790 aError == KErrTimedOut || |
|
791 ((aError == KErrSIPResolvingFailure || |
|
792 aError == KErrSIPTransportFailure || |
|
793 aError == KErrSIPICMPFailure) && |
|
794 iConnection.State() != CSIPConnection::ESuspended)); |
|
795 } |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CSIPIMSProfileContext::RetryAfterTimer |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 TBool CSIPIMSProfileContext::RetryAfterTimer() |
|
802 { |
|
803 return ( iRetryCounterSum == 1 && iRetriedRegister ); |
|
804 } |
|
805 |
|
806 // ----------------------------------------------------------------------------- |
|
807 // CSIPIMSProfileContext::ResolveProxyL |
|
808 // ----------------------------------------------------------------------------- |
|
809 // |
|
810 void CSIPIMSProfileContext::ResolveProxyL() |
|
811 { |
|
812 iConnectionContext.ResolveL(); |
|
813 } |
|
814 |
|
815 // ----------------------------------------------------------------------------- |
|
816 // CSIPIMSProfileContext::CancelProxyResolving |
|
817 // ----------------------------------------------------------------------------- |
|
818 // |
|
819 void CSIPIMSProfileContext::CancelProxyResolving() |
|
820 { |
|
821 iConnectionContext.CleanProxyResolving(); |
|
822 } |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // CSIPIMSProfileContext::ProxiesAlreadyResolved() |
|
826 // ----------------------------------------------------------------------------- |
|
827 // |
|
828 TBool CSIPIMSProfileContext::ProxiesAlreadyResolved() |
|
829 { |
|
830 if ( iProfile->DynamicProxy() != KNullDesC8 && |
|
831 iProxies == NULL && |
|
832 iUseDynamicProxyForTry) |
|
833 { |
|
834 iUseDynamicProxyForTry = EFalse; |
|
835 return ETrue; |
|
836 } |
|
837 return (iProxies && iProxies->MdcaCount() > 0); |
|
838 } |
|
839 |
|
840 // ----------------------------------------------------------------------------- |
|
841 // CSIPIMSProfileContext::CheckRetryAfter |
|
842 // ----------------------------------------------------------------------------- |
|
843 // |
|
844 void CSIPIMSProfileContext::CheckRetryAfter( CSIPClientTransaction* aTransaction ) |
|
845 { |
|
846 iRetryAfterTime = 0; |
|
847 if ( aTransaction && aTransaction->ResponseElements() ) |
|
848 { |
|
849 const RPointerArray<CSIPHeaderBase>& headers = |
|
850 aTransaction->ResponseElements()->MessageElements().UserHeaders(); |
|
851 TBool firstfound = EFalse; |
|
852 for ( TInt i=0; i < headers.Count() && !firstfound; i++ ) |
|
853 { |
|
854 if (headers[i]->Name() == |
|
855 SIPStrings::StringF( SipStrConsts::ERetryAfter )) |
|
856 { |
|
857 iRetryTimerUse = ETrue; |
|
858 CSIPRetryAfterHeader* retryAfter = |
|
859 (static_cast<CSIPRetryAfterHeader*>(headers[i])); |
|
860 iRetryAfterTime = retryAfter->RetryAfter(); |
|
861 firstfound = ETrue; |
|
862 } |
|
863 } |
|
864 } |
|
865 } |
|
866 |
|
867 // ----------------------------------------------------------------------------- |
|
868 // CSIPIMSProfileContext::RetryTimerInUse() |
|
869 // (other items were commented in a header). |
|
870 // ----------------------------------------------------------------------------- |
|
871 // |
|
872 TBool CSIPIMSProfileContext::RetryTimerInUse() |
|
873 { |
|
874 return (iRetryTimerUse && iRetryAfterTime); |
|
875 } |
|
876 |
|
877 // ----------------------------------------------------------------------------- |
|
878 // CSIPIMSProfileContext::RetryAfterTime() |
|
879 // (other items were commented in a header). |
|
880 // ----------------------------------------------------------------------------- |
|
881 // |
|
882 TUint CSIPIMSProfileContext::RetryAfterTime() |
|
883 { |
|
884 return iRetryAfterTime; |
|
885 } |
|
886 |
|
887 // ----------------------------------------------------------------------------- |
|
888 // CSIPIMSProfileContext::InitializeRetryTimerValue() |
|
889 // (other items were commented in a header). |
|
890 // ----------------------------------------------------------------------------- |
|
891 // |
|
892 void CSIPIMSProfileContext::InitializeRetryTimerValue() |
|
893 { |
|
894 iRetryAfterTime = 0; |
|
895 iRetryTimerUse = EFalse; |
|
896 } |
|
897 |
|
898 // ----------------------------------------------------------------------------- |
|
899 // CSIPIMSProfileContext::HasTransaction |
|
900 // From CSIPProfileContextBase |
|
901 // ----------------------------------------------------------------------------- |
|
902 // |
|
903 TBool CSIPIMSProfileContext::HasTransaction( |
|
904 const CSIPClientTransaction& aTransaction) const |
|
905 { |
|
906 if (iRegEventHandler && iRegEventHandler->HasTransaction(aTransaction)) |
|
907 { |
|
908 return ETrue; |
|
909 } |
|
910 return CSIPProfileContextBase::HasTransaction(aTransaction); |
|
911 } |
|
912 |
|
913 // ----------------------------------------------------------------------------- |
|
914 // CSIPIMSProfileContext::HasRefresh |
|
915 // From CSIPProfileContextBase |
|
916 // ----------------------------------------------------------------------------- |
|
917 // |
|
918 TBool CSIPIMSProfileContext::HasRefresh(const CSIPRefresh& aRefresh) const |
|
919 { |
|
920 if (iRegEventHandler && iRegEventHandler->HasRefresh(aRefresh)) |
|
921 { |
|
922 return ETrue; |
|
923 } |
|
924 return CSIPProfileContextBase::HasRefresh(aRefresh); |
|
925 } |
|
926 |
|
927 // ----------------------------------------------------------------------------- |
|
928 // CSIPIMSProfileContext::RegistrarUsername |
|
929 // From CSIPProfileContextBase |
|
930 // ----------------------------------------------------------------------------- |
|
931 // |
|
932 const TDesC8& CSIPIMSProfileContext::RegistrarUsername() const |
|
933 { |
|
934 if (iProfile) |
|
935 { |
|
936 if (iProfile->PrivateIdentity().Length() > 0) |
|
937 { |
|
938 return iProfile->PrivateIdentity(); |
|
939 } |
|
940 else |
|
941 { |
|
942 return iProfile->ServerParameter(KSIPRegistrar, KSIPDigestUserName); |
|
943 } |
|
944 } |
|
945 return KNullDesC8; |
|
946 } |
|
947 |
|
948 // ----------------------------------------------------------------------------- |
|
949 // CSIPIMSProfileContext::IncomingRequest() |
|
950 // (other items were commented in a header). |
|
951 // ----------------------------------------------------------------------------- |
|
952 // |
|
953 void CSIPIMSProfileContext::IncomingRequest( |
|
954 CSIPServerTransaction* aTransaction, |
|
955 CSIPDialog& aDialog, |
|
956 TBool& aHandled) |
|
957 { |
|
958 if(iRegEventHandler && iRegEventHandler->HasDialog(aDialog)) |
|
959 { |
|
960 TRAPD(err, iRegEventHandler->RequestReceivedL(aTransaction, aDialog)); |
|
961 if (err) |
|
962 { |
|
963 delete aTransaction; |
|
964 } |
|
965 aHandled = ETrue; |
|
966 } |
|
967 } |
|
968 |
|
969 // ----------------------------------------------------------------------------- |
|
970 // CSIPIMSProfileContext::IncomingResponse() |
|
971 // (other items were commented in a header). |
|
972 // ----------------------------------------------------------------------------- |
|
973 // |
|
974 void CSIPIMSProfileContext::IncomingResponse( |
|
975 CSIPClientTransaction& aTransaction, |
|
976 TBool& aHandled) |
|
977 { |
|
978 if(iRegEventHandler && iRegEventHandler->HasTransaction(aTransaction)) |
|
979 { |
|
980 TRAP_IGNORE(iRegEventHandler->ResponseReceivedL(aTransaction)) |
|
981 aHandled = ETrue; |
|
982 } |
|
983 } |
|
984 |
|
985 // ----------------------------------------------------------------------------- |
|
986 // CSIPIMSProfileContext::IncomingResponse() |
|
987 // (other items were commented in a header). |
|
988 // ----------------------------------------------------------------------------- |
|
989 // |
|
990 void CSIPIMSProfileContext::IncomingResponse( |
|
991 CSIPClientTransaction& aTransaction, |
|
992 CSIPDialogAssocBase& aDialogAssoc, |
|
993 TBool& aHandled) |
|
994 { |
|
995 if(iRegEventHandler && iRegEventHandler->HasDialog(aDialogAssoc.Dialog())) |
|
996 { |
|
997 TRAP_IGNORE(iRegEventHandler->ResponseReceivedL(aTransaction)) |
|
998 aHandled = ETrue; |
|
999 } |
|
1000 } |
|
1001 |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // CSIPIMSProfileContext::ErrorOccured() |
|
1004 // (other items were commented in a header). |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // |
|
1007 void CSIPIMSProfileContext::ErrorOccured( |
|
1008 CSIPDialogAssocBase& aDialogAssoc, |
|
1009 TInt aError, |
|
1010 TBool& aHandled) |
|
1011 { |
|
1012 if(iRegEventHandler && iRegEventHandler->HasDialog(aDialogAssoc.Dialog())) |
|
1013 { |
|
1014 iRegEventHandler->ErrorOccured(aError,aDialogAssoc.Dialog()); |
|
1015 aHandled = ETrue; |
|
1016 } |
|
1017 } |
|
1018 |
|
1019 // ----------------------------------------------------------------------------- |
|
1020 // CSIPIMSProfileContext::ErrorOccured() |
|
1021 // (other items were commented in a header). |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // |
|
1024 void CSIPIMSProfileContext::ErrorOccured( |
|
1025 CSIPTransactionBase& aTransaction, |
|
1026 CSIPDialogAssocBase& aDialogAssoc, |
|
1027 TInt aError, |
|
1028 TBool& aHandled) |
|
1029 { |
|
1030 if(iRegEventHandler && iRegEventHandler->HasDialog(aDialogAssoc.Dialog())) |
|
1031 { |
|
1032 iRegEventHandler->ErrorOccured(aError,aTransaction); |
|
1033 aHandled = ETrue; |
|
1034 } |
|
1035 } |
|
1036 |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // CSIPIMSProfileContext::IsHttpDigestSettingsConfigured |
|
1039 // (other items were commented in a header). |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // |
|
1042 TBool CSIPIMSProfileContext::IsHttpDigestSettingsConfigured( |
|
1043 const CSIPConcreteProfile& aProfile) |
|
1044 { |
|
1045 if ((aProfile.PrivateIdentity().Length() || |
|
1046 aProfile.ServerParameter(KSIPRegistrar, KSIPDigestUserName).Length()) |
|
1047 && |
|
1048 aProfile.ServerParameter(KSIPRegistrar, KSIPDigestPassword).Length()) |
|
1049 { |
|
1050 return ETrue; |
|
1051 } |
|
1052 return EFalse; |
|
1053 } |
|
1054 |
|
1055 // ----------------------------------------------------------------------------- |
|
1056 // CSIPIMSProfileContext::IsSupportedSecurityMechanismL |
|
1057 // (other items were commented in a header). |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // |
|
1060 TBool CSIPIMSProfileContext::IsSupportedSecurityMechanismL( |
|
1061 CSIP& aSIP, |
|
1062 const TDesC8& aValue) |
|
1063 { |
|
1064 TBool result = EFalse; |
|
1065 CDesC8Array* mechanisms = aSIP.SupportedSecurityMechanismsL(); |
|
1066 CleanupStack::PushL(mechanisms); |
|
1067 for (TInt i = 0; mechanisms && (i < mechanisms->MdcaCount()); i++) |
|
1068 { |
|
1069 if(mechanisms->MdcaPoint(i).Compare(aValue) == 0) |
|
1070 { |
|
1071 result = ETrue; |
|
1072 } |
|
1073 } |
|
1074 CleanupStack::PopAndDestroy(mechanisms); |
|
1075 return result; |
|
1076 } |
|
1077 |
|
1078 // ----------------------------------------------------------------------------- |
|
1079 // CSIPIMSProfileContext::SetConfiguredType() |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // |
|
1082 void CSIPIMSProfileContext::SetConfiguredType(TConfiguredType aConfiguredType) |
|
1083 { |
|
1084 iConfiguredType = aConfiguredType; |
|
1085 } |
|
1086 |
|
1087 // ----------------------------------------------------------------------------- |
|
1088 // CSIPIMSProfileContext::ConfiguredType() |
|
1089 // ----------------------------------------------------------------------------- |
|
1090 // |
|
1091 CSIPIMSProfileContext::TConfiguredType CSIPIMSProfileContext::ConfiguredType() |
|
1092 { |
|
1093 return iConfiguredType; |
|
1094 } |
|
1095 |
|
1096 // ----------------------------------------------------------------------------- |
|
1097 // CSIPIMSProfileContext::ConnectionStateChangedImpl |
|
1098 // ----------------------------------------------------------------------------- |
|
1099 // |
|
1100 void CSIPIMSProfileContext::ConnectionStateChangedImpl( |
|
1101 CSIPConnection::TState aState) |
|
1102 { |
|
1103 PROFILE_DEBUG4("CSIPIMSProfileContext::ConnectionStateChangedImpl" |
|
1104 ,ProfileId(), aState) |
|
1105 if (aState == CSIPConnection::EActive) |
|
1106 { |
|
1107 if (iRegEventHandler && |
|
1108 iConnectionContext.PreviousSIPConnectionState() == |
|
1109 CSIPConnection::ESuspended) |
|
1110 { |
|
1111 TRAP_IGNORE(iRegEventHandler->RefreshL()) |
|
1112 } |
|
1113 } |
|
1114 else |
|
1115 { |
|
1116 if (iConnectionContext.PreviousSIPConnectionState() == |
|
1117 CSIPConnection::EActive) |
|
1118 { |
|
1119 iConnectionDropped = ETrue; |
|
1120 } |
|
1121 } |
|
1122 } |
|
1123 |
|
1124 // ----------------------------------------------------------------------------- |
|
1125 // CSIPIMSProfileContext::SetRegisteredAORsL |
|
1126 // ----------------------------------------------------------------------------- |
|
1127 // |
|
1128 void CSIPIMSProfileContext::SetRegisteredAORsL() |
|
1129 { |
|
1130 if (iProfile) |
|
1131 { |
|
1132 CDesC8ArrayFlat* array = new(ELeave)CDesC8ArrayFlat(1); |
|
1133 CleanupStack::PushL(array); |
|
1134 if (!iPAURI) |
|
1135 { |
|
1136 if (iConfiguredType == |
|
1137 CSIPIMSProfileContext::EClientConfiguredType || |
|
1138 iSIMRecord.IsISIMPresent()) |
|
1139 { |
|
1140 // SUBSCRIBE to reg-event with the AOR used in REGISTER |
|
1141 TUriParser8 parser; |
|
1142 if (iConfiguredType == CSIPIMSProfileContext::EIMSReleaseType) |
|
1143 { |
|
1144 User::LeaveIfError(parser.Parse(iSIMRecord.PublicIdentity())); |
|
1145 } |
|
1146 else |
|
1147 { |
|
1148 User::LeaveIfError(parser.Parse(iProfile->AOR())); |
|
1149 } |
|
1150 TInt err = parser.Validate(); |
|
1151 if (err != KErrNone && err != KErrNotSupported) |
|
1152 { |
|
1153 User::Leave(err); |
|
1154 } |
|
1155 iPAURI = CUri8::NewL(parser); |
|
1156 } |
|
1157 else |
|
1158 { |
|
1159 // USIM or SIM used. |
|
1160 // Temporary ID cannot be used in reg-event subscription. |
|
1161 User::Leave(KErrNotSupported); |
|
1162 } |
|
1163 } |
|
1164 array->AppendL(iPAURI->Uri().UriDes()); |
|
1165 iProfile->SetRegisteredAORsL(*array); |
|
1166 CleanupStack::PopAndDestroy(array); |
|
1167 if (iRegistration && iRegistration->RegisteredContact()) |
|
1168 { |
|
1169 HBufC8* contact = |
|
1170 iRegistration->RegisteredContact()->ToTextValueLC(); |
|
1171 iProfile->SetExtensionParameterL(KSIPRegisteredContact,*contact); |
|
1172 CleanupStack::PopAndDestroy(contact); |
|
1173 } |
|
1174 } |
|
1175 } |
|
1176 |
|
1177 // ----------------------------------------------------------------------------- |
|
1178 // CSIPIMSProfileContext::RemoveRegEventHandler |
|
1179 // ----------------------------------------------------------------------------- |
|
1180 // |
|
1181 void CSIPIMSProfileContext::RemoveRegEventHandler() |
|
1182 { |
|
1183 delete iRegEventHandler; |
|
1184 iRegEventHandler = NULL; |
|
1185 } |
|
1186 |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // CSIPIMSProfileContext::StoreMsgElementsL |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // |
|
1191 void CSIPIMSProfileContext::StoreMsgElementsL() |
|
1192 { |
|
1193 delete iPAURI; |
|
1194 iPAURI = 0; |
|
1195 if (iClientTx && |
|
1196 iClientTx->ResponseElements() && |
|
1197 iClientTx->ResponseElements()->StatusCode() >= K200Ok && |
|
1198 iClientTx->ResponseElements()->StatusCode() < K300MultipleChoices) |
|
1199 { |
|
1200 const RPointerArray<CSIPHeaderBase>& headers = |
|
1201 iClientTx->ResponseElements()->MessageElements().UserHeaders(); |
|
1202 TBool firstfound = EFalse; |
|
1203 for (TInt i=0; i < headers.Count() && !firstfound; i++) |
|
1204 { |
|
1205 if (headers[i]->Name() == |
|
1206 SIPStrings::StringF(SipStrConsts::EPAssociatedURIHeader)) |
|
1207 { |
|
1208 CSIPPAssociatedURIHeader* associatedURI = |
|
1209 (static_cast<CSIPPAssociatedURIHeader*>(headers[i])); |
|
1210 const TUriC8& uri = associatedURI->SIPAddress().Uri8().Uri(); |
|
1211 TInt err = uri.Validate(); |
|
1212 if (err != KErrNone && err != KErrNotSupported) |
|
1213 { |
|
1214 User::Leave(err); |
|
1215 } |
|
1216 iPAURI = CUri8::NewL(uri); |
|
1217 firstfound = ETrue; |
|
1218 } |
|
1219 } |
|
1220 } |
|
1221 } |
|
1222 |
|
1223 // ----------------------------------------------------------------------------- |
|
1224 // CSIPIMSProfileContext::IsUnsupportedHeaderValue() |
|
1225 // ----------------------------------------------------------------------------- |
|
1226 // |
|
1227 TBool CSIPIMSProfileContext::IsUnsupportedHeaderValue(RStringF aValue) |
|
1228 { |
|
1229 const RPointerArray<CSIPHeaderBase>& headers = |
|
1230 iClientTx->ResponseElements()->MessageElements().UserHeaders(); |
|
1231 for (TInt i = 0; i < headers.Count();i++) |
|
1232 { |
|
1233 if (headers[i]->Name() == |
|
1234 SIPStrings::StringF(SipStrConsts::EUnsupportedHeader)) |
|
1235 { |
|
1236 CSIPUnsupportedHeader* unsupported = |
|
1237 (static_cast<CSIPUnsupportedHeader*>(headers[i])); |
|
1238 if (unsupported->Value() == aValue) |
|
1239 { |
|
1240 return ETrue; |
|
1241 } |
|
1242 else |
|
1243 { |
|
1244 return EFalse; |
|
1245 } |
|
1246 } |
|
1247 } |
|
1248 return EFalse; |
|
1249 } |
|
1250 |
|
1251 // ----------------------------------------------------------------------------- |
|
1252 // CSIPIMSProfileContext::AddSecurityClientHeaderL |
|
1253 // ----------------------------------------------------------------------------- |
|
1254 // |
|
1255 void CSIPIMSProfileContext::AddSecurityClientHeaderL( |
|
1256 RPointerArray<CSIPHeaderBase>& aHeaders, |
|
1257 const CSIPConcreteProfile& aProfile) |
|
1258 { |
|
1259 if (aProfile.IsSecurityNegotiationEnabled() && |
|
1260 iConfiguredType != CSIPIMSProfileContext::EEarlyIMSType) |
|
1261 { |
|
1262 TPtrC8 mechanism(KSIPIpSec3gpp); |
|
1263 if (IsHttpDigestSettingsConfigured(aProfile)) |
|
1264 { |
|
1265 mechanism.Set(KSIPdigest); |
|
1266 } |
|
1267 CSIPSecurityClientHeader* header = |
|
1268 CSIPSecurityClientHeader::NewLC(mechanism); |
|
1269 aHeaders.AppendL(header); |
|
1270 CleanupStack::Pop(header); |
|
1271 } |
|
1272 } |
|
1273 |
|
1274 // ----------------------------------------------------------------------------- |
|
1275 // CSIPIMSProfileContext::HandleProfileRegisteredEventL |
|
1276 // ----------------------------------------------------------------------------- |
|
1277 // |
|
1278 void CSIPIMSProfileContext::HandleProfileRegisteredEventL() |
|
1279 { |
|
1280 if (iPAURI) |
|
1281 { |
|
1282 CSIPRegEventHandler* regEventHandler = |
|
1283 CSIPRegEventHandler::NewL(iXMLParser, |
|
1284 iConnectionContext.LocalIPAddress(), |
|
1285 iDeltaTimer,iConnection, |
|
1286 *iRegistration,*iPAURI,*this,iConfigExtension); |
|
1287 CleanupStack::PushL(regEventHandler); |
|
1288 regEventHandler->SubscribeL(); |
|
1289 delete iRegEventHandler; |
|
1290 iRegEventHandler = regEventHandler; |
|
1291 CleanupStack::Pop(regEventHandler); |
|
1292 delete iPAURI; |
|
1293 iPAURI = 0; |
|
1294 } |
|
1295 } |
|
1296 |
|
1297 // ----------------------------------------------------------------------------- |
|
1298 // CSIPIMSProfileContext::CreateMsgElementsForUpdateLC |
|
1299 // ----------------------------------------------------------------------------- |
|
1300 // |
|
1301 CSIPMessageElements* CSIPIMSProfileContext::CreateMsgElementsForUpdateLC( |
|
1302 CSIPConcreteProfile& aProfile) |
|
1303 { |
|
1304 CSIPMessageElements* elements = CSIPMessageElements::NewLC(); |
|
1305 RPointerArray<CSIPHeaderBase> headers(CreateSIPHeadersL(aProfile)); |
|
1306 CSIPHeaderBase::PushLC(&headers); |
|
1307 AddSecurityClientHeaderL(headers,aProfile); |
|
1308 elements->SetUserHeadersL(headers); |
|
1309 CleanupStack::PopAndDestroy(&headers); |
|
1310 return elements; |
|
1311 } |
|
1312 |
|
1313 // ----------------------------------------------------------------------------- |
|
1314 // CSIPIMSProfileContext::CreateSIPHeadersL |
|
1315 // ----------------------------------------------------------------------------- |
|
1316 // |
|
1317 RPointerArray<CSIPHeaderBase> CSIPIMSProfileContext::CreateSIPHeadersL( |
|
1318 const CSIPConcreteProfile& aProfile) |
|
1319 { |
|
1320 RPointerArray<CSIPHeaderBase> headers; |
|
1321 CSIPHeaderBase::PushLC(&headers); |
|
1322 |
|
1323 TInt sipHeaderCount = aProfile.SIPHeaders().MdcaCount(); |
|
1324 for (TInt i=0; i < sipHeaderCount; i++) |
|
1325 { |
|
1326 TPtrC8 headerDes(aProfile.SIPHeaders().MdcaPoint(i)); |
|
1327 CSIPHeaderBase* header = SIPMessageBuilder::CreateHeaderLC(headerDes); |
|
1328 headers.AppendL(header); |
|
1329 CleanupStack::Pop(header); |
|
1330 } |
|
1331 |
|
1332 CleanupStack::Pop(&headers); |
|
1333 return headers; |
|
1334 } |
|
1335 |
|
1336 // ----------------------------------------------------------------------------- |
|
1337 // CSIPIMSProfileContext::TransportProtocol |
|
1338 // ----------------------------------------------------------------------------- |
|
1339 // |
|
1340 RStringF CSIPIMSProfileContext::TransportProtocol(const CUri8& aUri) const |
|
1341 { |
|
1342 RStringF transport(SIPStrings::StringF(SipStrConsts::EEmpty)); |
|
1343 if (aUri.Uri().Extract(EUriPath).FindF(KTransportUdpParam) >= 0) |
|
1344 { |
|
1345 transport = SIPStrings::StringF(SipStrConsts::EUdp); |
|
1346 } |
|
1347 if (aUri.Uri().Extract(EUriPath).FindF(KTransportTcpParam) >= 0) |
|
1348 { |
|
1349 transport = SIPStrings::StringF(SipStrConsts::ETcp); |
|
1350 } |
|
1351 return transport; |
|
1352 } |