|
1 // Copyright (c) 2003-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 : sipietfprofileagent.cpp |
|
15 // Part of : sip ietf plugin |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "sipietfprofileagent.h" |
|
25 #include "sipconcreteprofile.h" |
|
26 #include "sipprofileagentobserver.h" |
|
27 #include "sipconnection.h" |
|
28 #include "sipprflinitstate.h" |
|
29 #include "sipprflresolvingproxiesstate.h" |
|
30 #include "sipprflregisterrequestedstate.h" |
|
31 #include "sipprflregisterdelayrequestedstate.h" |
|
32 #include "sipprflregistrationinprogressstate.h" |
|
33 #include "sipprflregisteredstate.h" |
|
34 #include "sipprflderegistrationinprogressstate.h" |
|
35 #include "sipprflderegisterrequestedstate.h" |
|
36 #include "sipprflstatebase.h" |
|
37 #include "sipietfprofilecontext.h" |
|
38 #include "sipgendefs.h" |
|
39 #include "SipProfileLog.h" |
|
40 #include "sipstrings.h" |
|
41 #include "sipstrconsts.h" |
|
42 #include "sipprofilequeuehandling.h" |
|
43 #include <sip.h> |
|
44 #include <siphttpdigest.h> |
|
45 #include <sipservertransaction.h> |
|
46 #include <sipprofile.h> |
|
47 |
|
48 _LIT8(KSIPIETFProfileType, "IETF"); |
|
49 |
|
50 // ============================ MEMBER FUNCTIONS =============================== |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CSIPIetfProfileAgent::NewL |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CSIPIetfProfileAgent* CSIPIetfProfileAgent::NewL(TAny* aInitParams) |
|
58 { |
|
59 CSIPIetfProfileAgent* self = new (ELeave) CSIPIetfProfileAgent( |
|
60 static_cast<TSIPProfileAgentInitParams*>(aInitParams)); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CSIPIetfProfileAgent::CSIPIetfProfileAgent |
|
69 // C++ default constructor can NOT contain any code, that |
|
70 // might leave. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CSIPIetfProfileAgent::CSIPIetfProfileAgent( |
|
74 TSIPProfileAgentInitParams* aInitParams) |
|
75 : iSIPProfileAgentObserver(aInitParams->iSIPProfileAgentObserver), |
|
76 iDeltaTimer(aInitParams->iDeltaTimer) |
|
77 { |
|
78 iType.iSIPProfileClass = TSIPProfileTypeInfo::EInternet; |
|
79 iType.iSIPProfileName = KSIPIetfType(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CSIPIetfProfileAgent::ConstructL |
|
84 // Symbian 2nd phase constructor can leave. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CSIPIetfProfileAgent::ConstructL() |
|
88 { |
|
89 SIPStrings::OpenL(); |
|
90 iInit = CSIPPrflInitState::NewL(*this); |
|
91 iResolvingProxies = CSIPPrflResolvingProxiesState::NewL(*this); |
|
92 iRegRequested = CSIPPrflRegisterRequestedState::NewL(*this); |
|
93 iRegInProgress = CSIPPrflRegistrationInProgressState::NewL(*this); |
|
94 iRegistered = CSIPPrflRegisteredState::NewL(*this); |
|
95 iDeregRequested = CSIPPrflDeregisterRequestedState::NewL(*this); |
|
96 iDeregInProgress = CSIPPrflDeregistrationInProgressState::NewL(*this); |
|
97 iRegDelayRequested = CSIPPrflRegisterDelayRequestedState::NewL(*this); |
|
98 iInit->LinkStates(*iResolvingProxies, *iRegRequested, *iRegInProgress); |
|
99 iResolvingProxies->LinkStates(*iInit, *iRegRequested, *iRegInProgress); |
|
100 iRegRequested->LinkStates(*iInit, *iResolvingProxies, *iRegInProgress); |
|
101 iRegInProgress->LinkStates(*iRegRequested, *iInit, *iRegistered, |
|
102 *iRegDelayRequested); |
|
103 iRegistered->LinkStates(*iDeregRequested, *iDeregInProgress, |
|
104 *iInit, *iRegRequested,*iRegDelayRequested); |
|
105 iDeregRequested->LinkStates(*iInit, *iRegistered, *iDeregInProgress); |
|
106 iDeregInProgress->LinkStates(*iInit); |
|
107 iRegDelayRequested->LinkStates(*iInit); |
|
108 iProfileQueueHandling = CSIPProfileQueueHandling::NewL(*this); |
|
109 |
|
110 iSIP = CSIP::NewL(TUid::Null(),*this); |
|
111 iHttpDigest = CSIPHttpDigest::NewL(*iSIP,*this); |
|
112 iConfigExtension = NULL; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CSIPIetfProfileAgent::~CSIPIetfProfileAgent |
|
117 // Symbian 2nd phase constructor can leave. |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 CSIPIetfProfileAgent::~CSIPIetfProfileAgent() |
|
121 { |
|
122 delete iInit; |
|
123 delete iResolvingProxies; |
|
124 delete iRegRequested; |
|
125 delete iRegistered; |
|
126 delete iRegInProgress; |
|
127 delete iDeregRequested; |
|
128 delete iDeregInProgress; |
|
129 delete iRegDelayRequested; |
|
130 delete iProfileQueueHandling; |
|
131 iConnectionCtxArray.ResetAndDestroy(); |
|
132 iConnectionCtxArray.Close(); |
|
133 SIPStrings::Close(); |
|
134 delete iHttpDigest; |
|
135 delete iSIP; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CSIPIetfProfileAgent::SIPProfileAgentType |
|
140 // (other items were commented in a header). |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 const TSIPProfileTypeInfo& CSIPIetfProfileAgent::Type() const |
|
144 { |
|
145 return iType; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CSIPIetfProfileAgent::CreateL |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 CSIPConcreteProfile* CSIPIetfProfileAgent::CreateL() |
|
153 { |
|
154 TSIPProfileTypeInfo type; |
|
155 type.iSIPProfileClass = TSIPProfileTypeInfo::EInternet; |
|
156 type.iSIPProfileName = KSIPIETFProfileType; |
|
157 |
|
158 CSIPConcreteProfile* profile = CSIPConcreteProfile::NewL(); |
|
159 profile->SetProfileType(type); |
|
160 return profile; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CSIPIetfProfileAgent::RegisterL |
|
165 // (other items were commented in a header). |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CSIPIetfProfileAgent::RegisterL( |
|
169 CSIPConcreteProfile& aSIPConcreteProfile) |
|
170 { |
|
171 __ASSERT_ALWAYS (aSIPConcreteProfile.AOR().Length() > 0, |
|
172 User::Leave(KErrArgument)); |
|
173 __ASSERT_ALWAYS (aSIPConcreteProfile.Server(KSIPRegistrar).Length(), |
|
174 User::Leave(KErrArgument)); |
|
175 |
|
176 PROFILE_DEBUG3("CSIPIetfProfileAgent::RegisterL", aSIPConcreteProfile.Id()) |
|
177 |
|
178 if (!iProfileQueueHandling->AddRegisterToQueueL( aSIPConcreteProfile, |
|
179 EFalse )) |
|
180 { |
|
181 CSIPIetfProfileContext* context = FindProfileContext(aSIPConcreteProfile); |
|
182 if (!context) |
|
183 { |
|
184 context = &ProvideProfileContextL(aSIPConcreteProfile); |
|
185 } |
|
186 context->RegisterL(); |
|
187 } |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CSIPIetfProfileAgent::UpdateL |
|
192 // (other items were commented in a header). |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void CSIPIetfProfileAgent::UpdateL( |
|
196 CSIPConcreteProfile& aNewProfile, |
|
197 CSIPConcreteProfile& aOldProfile) |
|
198 { |
|
199 PROFILE_DEBUG3("CSIPIetfProfileAgent::UpdateL", aOldProfile.Id()) |
|
200 iProfileQueueHandling->Cleanup(aOldProfile,&aNewProfile); |
|
201 CSIPIetfProfileContext* context = FindProfileContext(aOldProfile); |
|
202 if (!context) |
|
203 { |
|
204 User::Leave(KErrNotFound); |
|
205 } |
|
206 context->UpdateL(aNewProfile); |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CSIPIetfProfileAgent::DeregisterL |
|
211 // (other items were commented in a header). |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CSIPIetfProfileAgent::DeregisterL( |
|
215 CSIPConcreteProfile& aSIPConcreteProfile) |
|
216 { |
|
217 PROFILE_DEBUG3("CSIPIetfProfileAgent::DeregisterL", aSIPConcreteProfile.Id()) |
|
218 CSIPIetfProfileContext* context = FindProfileContext(aSIPConcreteProfile); |
|
219 if ( context ) |
|
220 { |
|
221 if ( !DeregisterToWaitingQueueL( context )) |
|
222 { |
|
223 context->DeregisterL(); |
|
224 } |
|
225 } |
|
226 else |
|
227 { |
|
228 iProfileQueueHandling->RemoveProfileFromRegQueueL(aSIPConcreteProfile); |
|
229 } |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CSIPIetfProfileAgent::GetProfileState |
|
234 // (other items were commented in a header). |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 TInt CSIPIetfProfileAgent::GetProfileState( |
|
238 CSIPConcreteProfile::TStatus& aState, |
|
239 CSIPConcreteProfile& aProfile) const |
|
240 { |
|
241 CSIPIetfProfileContext* context = FindProfileContext(aProfile); |
|
242 if (context) |
|
243 { |
|
244 aState = context->CurrentMappedState(); |
|
245 return KErrNone; |
|
246 } |
|
247 else |
|
248 { |
|
249 return KErrNotFound; |
|
250 } |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CSIPIetfProfileAgent::IsIdle |
|
255 // (other items were commented in a header). |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 TBool CSIPIetfProfileAgent::IsIdle() |
|
259 { |
|
260 CleanIdleConnectionContexts(); |
|
261 return (iConnectionCtxArray.Count()==0); |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CSIPIetfProfileAgent::RegisterPending |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 TBool CSIPIetfProfileAgent::RegisterPending( |
|
269 CSIPConcreteProfile& aSIPProfile) const |
|
270 { |
|
271 PROFILE_DEBUG3("CSIPIetfProfileAgent::IsRegisterPending", aSIPProfile.Id()) |
|
272 |
|
273 CSIPIetfProfileContext* context = FindProfileContext(aSIPProfile); |
|
274 if (context) |
|
275 { |
|
276 return context->IsRegisterPending(); |
|
277 } |
|
278 return EFalse; |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CSIPIetfProfileAgent::TerminateHandling |
|
283 // (other items were commented in a header). |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 TInt CSIPIetfProfileAgent::TerminateHandling(CSIPConcreteProfile& aProfile) |
|
287 { |
|
288 CSIPIetfProfileContext* context = FindProfileContext(aProfile); |
|
289 if (context) |
|
290 { |
|
291 PROFILE_DEBUG3("CSIPIetfProfileAgent::TerminateHandling", aProfile.Id()) |
|
292 context->SetNextState(*iInit); |
|
293 context->TerminateHandling(); |
|
294 return KErrNone; |
|
295 } |
|
296 else |
|
297 { |
|
298 return KErrNotFound; |
|
299 } |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // CSIPIetfProfileAgent::Extension |
|
304 // (other items were commented in a header). |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 TInt CSIPIetfProfileAgent::Extension(TInt aOperationCode, TAny* aParams) |
|
308 { |
|
309 TInt err(KErrNone); |
|
310 if(aParams && aOperationCode == KSipProfileAgentConfigExtension) |
|
311 iConfigExtension = static_cast<CSipProfileAgentConfigExtension*>(aParams); |
|
312 else |
|
313 err = KErrNotSupported; |
|
314 return err; |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CSIPIetfProfileAgent::SIPProfileStatusEvent |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 void CSIPIetfProfileAgent::SIPProfileStatusEvent( |
|
322 CSIPConcreteProfile& aProfile, |
|
323 TUint32 aContextId) |
|
324 { |
|
325 PROFILE_DEBUG4("CSIPIetfProfileAgent::SIPProfileStatusEvent",\ |
|
326 aProfile.Id(), aContextId) |
|
327 |
|
328 |
|
329 RegisterQueue( aProfile, ETrue ); |
|
330 |
|
331 iSIPProfileAgentObserver.SIPProfileStatusEvent( aProfile, aContextId ); |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CSIPIetfProfileAgent::SIPProfileErrorEvent |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void CSIPIetfProfileAgent::SIPProfileErrorEvent( |
|
339 CSIPConcreteProfile& aProfile, |
|
340 TInt aError) |
|
341 { |
|
342 PROFILE_DEBUG4("CSIPIetfProfileAgent::ErrorEvent", aProfile.Id(), aError) |
|
343 CSIPIetfProfileContext* context = FindProfileContext(aProfile.Id()); |
|
344 |
|
345 if (context && context->IgnoreErrorEvent()) |
|
346 { |
|
347 PROFILE_DEBUG4("CSIPIetfProfileAgent::Error ignored",\ |
|
348 aProfile.Id(), aError) |
|
349 } |
|
350 else |
|
351 { |
|
352 PROFILE_DEBUG4("CSIPIetfProfileAgent::Error sent", |
|
353 aProfile.Id(), aError) |
|
354 |
|
355 RegisterQueue( aProfile, EFalse ); |
|
356 |
|
357 iSIPProfileAgentObserver.SIPProfileErrorEvent(aProfile,aError); |
|
358 } |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // CSIPIetfProfileAgent::ProceedRegistration |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 TBool CSIPIetfProfileAgent::ProceedRegistration( |
|
366 CSIPConcreteProfile& aProfile, |
|
367 TInt aError) |
|
368 { |
|
369 PROFILE_DEBUG3("CSIPIetfProfileAgent::ProceedRegistration", aProfile.Id()) |
|
370 return iSIPProfileAgentObserver.ProceedRegistration(aProfile, aError); |
|
371 } |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CSIPIetfProfileAgent::GetFailedProfilesL |
|
375 // ----------------------------------------------------------------------------- |
|
376 // |
|
377 void CSIPIetfProfileAgent::GetFailedProfilesL( |
|
378 const TSIPProfileTypeInfo& /*aType*/, |
|
379 RPointerArray<CSIPConcreteProfile>& /*aFailedProfiles*/) const |
|
380 { |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // CSIPIetfProfileAgent::RegisterProfileL |
|
385 // From MSIPProfileFSMUser |
|
386 // ----------------------------------------------------------------------------- |
|
387 // |
|
388 void CSIPIetfProfileAgent::RegisterProfileL( |
|
389 CSIPConcreteProfile& aSIPProfile) |
|
390 { |
|
391 RegisterL(aSIPProfile); |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // CSIPIetfProfileAgent::DeregisterProfileL |
|
396 // From MSIPProfileFSMUser |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 void CSIPIetfProfileAgent::DeregisterProfileL( |
|
400 CSIPConcreteProfile& aSIPProfile) |
|
401 { |
|
402 DeregisterL(aSIPProfile); |
|
403 } |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // CSIPIetfProfileAgent::RetryProfileRegistrationL |
|
407 // From MSIPProfileFSMUser |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 void CSIPIetfProfileAgent::RetryProfileRegistrationL( |
|
411 CSIPConcreteProfile& aSIPProfile) |
|
412 { |
|
413 PROFILE_DEBUG3("CSIPIetfProfileAgent::RetryProfileRegistrationL", |
|
414 aSIPProfile.Id()) |
|
415 |
|
416 if (!iProfileQueueHandling->AddRegisterToQueueL(aSIPProfile, ETrue)) |
|
417 { |
|
418 CSIPIetfProfileContext* context = FindProfileContext(aSIPProfile); |
|
419 if (!context) |
|
420 { |
|
421 User::Leave(KErrNotFound); |
|
422 } |
|
423 context->RetryRegistration(); |
|
424 } |
|
425 } |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // CSIPIetfProfileAgent::AddProfileIntoQueue |
|
429 // From MSIPProfileFSMUser |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 TBool CSIPIetfProfileAgent::AddProfileIntoQueue( |
|
433 CSIPConcreteProfile& aSIPProfile) const |
|
434 { |
|
435 PROFILE_DEBUG3("CSIPIetfProfileAgent::AddProfileIntoQueue", |
|
436 aSIPProfile.Id()) |
|
437 |
|
438 TBool found = EFalse; |
|
439 for (TInt i=0; i < iConnectionCtxArray.Count() && !found; i++) |
|
440 { |
|
441 found = iConnectionCtxArray[i]->AddIntoQueue( |
|
442 aSIPProfile.Server(KSIPRegistrar)); |
|
443 } |
|
444 return found; |
|
445 } |
|
446 |
|
447 // ----------------------------------------------------------------------------- |
|
448 // CSIPIetfProfileAgent::RegisterProfileAfterQueueL |
|
449 // From MSIPProfileFSMUser |
|
450 // ----------------------------------------------------------------------------- |
|
451 // |
|
452 void CSIPIetfProfileAgent::RegisterProfileAfterQueueL( |
|
453 CSIPConcreteProfile& aSIPProfile) |
|
454 { |
|
455 PROFILE_DEBUG3("CSIPIetfProfileAgent::RegisterProfileAfterQueueL", |
|
456 aSIPProfile.Id()) |
|
457 |
|
458 CSIPIetfProfileContext* context = FindProfileContext(aSIPProfile); |
|
459 if (!context) |
|
460 { |
|
461 context = &ProvideProfileContextL(aSIPProfile); |
|
462 } |
|
463 context->RegisterL(); |
|
464 } |
|
465 |
|
466 // ----------------------------------------------------------------------------- |
|
467 // CSIPIetfProfileAgent::DeregisterProfileAfterQueueL |
|
468 // From MSIPProfileFSMUser |
|
469 // ----------------------------------------------------------------------------- |
|
470 // |
|
471 void CSIPIetfProfileAgent::DeregisterProfileAfterQueueL( |
|
472 CSIPConcreteProfile& aSIPProfile) |
|
473 { |
|
474 PROFILE_DEBUG3("CSIPIetfProfileAgent::DeregisterProfileAfterQueueL", |
|
475 aSIPProfile.Id()) |
|
476 |
|
477 CSIPIetfProfileContext* context = FindProfileContext(aSIPProfile); |
|
478 __ASSERT_ALWAYS(context != NULL, User::Leave(KErrNotFound)); |
|
479 context->DeregisterL(); |
|
480 } |
|
481 |
|
482 // ----------------------------------------------------------------------------- |
|
483 // CSIPIetfProfileAgent::RetryProfileRegistrationAfterQueueL |
|
484 // From MSIPProfileFSMUser |
|
485 // ----------------------------------------------------------------------------- |
|
486 // |
|
487 void CSIPIetfProfileAgent::RetryProfileRegistrationAfterQueueL( |
|
488 CSIPConcreteProfile& aSIPProfile) |
|
489 { |
|
490 PROFILE_DEBUG3("CSIPIetfProfileAgent::RetryProfileRegistrationAfterQueueL", |
|
491 aSIPProfile.Id()) |
|
492 |
|
493 CSIPIetfProfileContext* context = FindProfileContext(aSIPProfile); |
|
494 __ASSERT_ALWAYS(context != NULL, User::Leave(KErrNotFound)); |
|
495 context->RetryRegistration(); |
|
496 } |
|
497 |
|
498 // ----------------------------------------------------------------------------- |
|
499 // CSIPIetfProfileAgent::IsInQueue |
|
500 // From MSIPProfileFSMUser |
|
501 // ----------------------------------------------------------------------------- |
|
502 // |
|
503 TBool CSIPIetfProfileAgent::IsInQueue( |
|
504 CSIPConcreteProfile& aSIPProfile) const |
|
505 { |
|
506 PROFILE_DEBUG1("CSIPIetfProfileAgent::IsInQueue") |
|
507 PROFILE_DEBUG3("CSIPIetfProfileAgent::IsInQueue", |
|
508 aSIPProfile.Id()) |
|
509 return iProfileQueueHandling->IsInQueue(aSIPProfile); |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CSIPIetfProfileAgent::SetInterimProfile |
|
514 // (other items were commented in a header). |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 void CSIPIetfProfileAgent::SetInterimProfile( CSIPConcreteProfile* /*aSIPConcreteProfile*/ ) |
|
518 { |
|
519 |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // CSIPIetfProfileAgent::IncomingRequest |
|
524 // From MSIPObserver |
|
525 // ----------------------------------------------------------------------------- |
|
526 // |
|
527 void CSIPIetfProfileAgent::IncomingRequest( |
|
528 TUint32 /*aIapId*/, |
|
529 CSIPServerTransaction* aTransaction) |
|
530 { |
|
531 // Should not be called, because CSIP is created with a NULL UID |
|
532 // Delete the transaction to prevent amemory leak |
|
533 delete aTransaction; |
|
534 } |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // CSIPIetfProfileAgent::TimedOut |
|
538 // From MSIPObserver |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 void CSIPIetfProfileAgent::TimedOut(CSIPServerTransaction& /*aTransaction*/) |
|
542 { |
|
543 } |
|
544 |
|
545 // ----------------------------------------------------------------------------- |
|
546 // CSIPIetfProfileAgent::ChallengeReceived |
|
547 // From MSIPHttpDigestChallengeObserver2 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 void CSIPIetfProfileAgent::ChallengeReceived( |
|
551 const CSIPClientTransaction& aTransaction) |
|
552 { |
|
553 TBool found = EFalse; |
|
554 for (TInt i=0; i < iConnectionCtxArray.Count() && !found; i++) |
|
555 { |
|
556 found = |
|
557 iConnectionCtxArray[i]->SetCredentials(aTransaction,*iHttpDigest); |
|
558 } |
|
559 } |
|
560 |
|
561 // ----------------------------------------------------------------------------- |
|
562 // CSIPIetfProfileAgent::ChallengeReceived |
|
563 // From MSIPHttpDigestChallengeObserver2 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // |
|
566 void CSIPIetfProfileAgent::ChallengeReceived(const CSIPRefresh& aRefresh) |
|
567 { |
|
568 TBool found = EFalse; |
|
569 for (TInt i=0; i < iConnectionCtxArray.Count() && !found; i++) |
|
570 { |
|
571 found = iConnectionCtxArray[i]->SetCredentials(aRefresh,*iHttpDigest); |
|
572 } |
|
573 } |
|
574 |
|
575 // ---------------------------------------------------------------------------- |
|
576 // CSIPIetfProfileAgent::RegisterQueue |
|
577 // ---------------------------------------------------------------------------- |
|
578 // |
|
579 void CSIPIetfProfileAgent::RegisterQueue( |
|
580 CSIPConcreteProfile& aProfile, |
|
581 TBool aReportError ) |
|
582 { |
|
583 PROFILE_DEBUG3("CSIPIetfProfileAgent::RegisterQueue", aProfile.Id()) |
|
584 |
|
585 TInt err( KErrNone ); |
|
586 |
|
587 if ( AllowedTakeFromQueue( aProfile ) ) |
|
588 { |
|
589 TRAP( err, iProfileQueueHandling->RegisterFromQueueL( aProfile ) ); |
|
590 } |
|
591 |
|
592 if ( err && aReportError ) |
|
593 { |
|
594 iSIPProfileAgentObserver.SIPProfileErrorEvent( aProfile, err ); |
|
595 } |
|
596 } |
|
597 |
|
598 // ----------------------------------------------------------------------------- |
|
599 // CSIPIetfProfileAgent::AllowedTakeFromQueue |
|
600 // ----------------------------------------------------------------------------- |
|
601 // |
|
602 TBool CSIPIetfProfileAgent::AllowedTakeFromQueue( |
|
603 CSIPConcreteProfile& aSIPConcreteProfile ) |
|
604 { |
|
605 PROFILE_DEBUG3("CSIPIetfProfileAgent::AllowedTakeFromQueueL", |
|
606 aSIPConcreteProfile.Id()) |
|
607 |
|
608 return !AddProfileIntoQueue( aSIPConcreteProfile ); |
|
609 } |
|
610 |
|
611 // ----------------------------------------------------------------------------- |
|
612 // CSIPIetfProfileAgent::DeregisterToWaitingQueueL |
|
613 // (other items were commented in a header). |
|
614 // ----------------------------------------------------------------------------- |
|
615 // |
|
616 TBool CSIPIetfProfileAgent::DeregisterToWaitingQueueL( |
|
617 CSIPIetfProfileContext* aContext ) |
|
618 { |
|
619 PROFILE_DEBUG3("CSIPIetfProfileAgent::DeregisterToWaitingQueueL", |
|
620 aContext->Profile()->Id()) |
|
621 return iProfileQueueHandling->AddDeregisterToQueueL( *aContext->Profile() ); |
|
622 } |
|
623 |
|
624 // ----------------------------------------------------------------------------- |
|
625 // CSIPIetfProfileAgent::FindProfileContext |
|
626 // (other items were commented in a header). |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 CSIPIetfProfileContext* CSIPIetfProfileAgent::FindProfileContext( |
|
630 CSIPConcreteProfile& aSIPConcreteProfile) const |
|
631 { |
|
632 return FindProfileContext(aSIPConcreteProfile.Id()); |
|
633 } |
|
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // CSIPIetfProfileAgent::FindProfileContext |
|
637 // (other items were commented in a header). |
|
638 // ----------------------------------------------------------------------------- |
|
639 // |
|
640 CSIPIetfProfileContext* CSIPIetfProfileAgent::FindProfileContext( |
|
641 TUint32 aProfileId) const |
|
642 { |
|
643 for (TInt i=0; i < iConnectionCtxArray.Count(); i++) |
|
644 { |
|
645 CSIPIetfProfileContext *context = |
|
646 iConnectionCtxArray[i]->FindContext(aProfileId); |
|
647 if (context) |
|
648 { |
|
649 return context; |
|
650 } |
|
651 } |
|
652 return 0; |
|
653 } |
|
654 |
|
655 // ----------------------------------------------------------------------------- |
|
656 // CSIPIetfProfileAgent::FindConnectionContext |
|
657 // (other items were commented in a header). |
|
658 // ----------------------------------------------------------------------------- |
|
659 // |
|
660 CSIPIetfConnectionContext* CSIPIetfProfileAgent::FindConnectionContext( |
|
661 CSIPConcreteProfile& aProfile) const |
|
662 { |
|
663 CSIPIetfConnectionContext* context =0; |
|
664 TBool found = EFalse; |
|
665 for (TInt i=0; i < iConnectionCtxArray.Count() && !found; i++) |
|
666 { |
|
667 if ( iConnectionCtxArray[i]->ConnectionUser( aProfile ) ) |
|
668 { |
|
669 context = iConnectionCtxArray[i]; |
|
670 found = ETrue; |
|
671 } |
|
672 } |
|
673 return context; |
|
674 } |
|
675 |
|
676 // ----------------------------------------------------------------------------- |
|
677 // CSIPIetfProfileAgent::FindConnectionContext |
|
678 // (other items were commented in a header). |
|
679 // ----------------------------------------------------------------------------- |
|
680 // |
|
681 CSIPIetfConnectionContext* CSIPIetfProfileAgent::FindConnectionContext( |
|
682 TUint32 aIapId ) const |
|
683 { |
|
684 CSIPIetfConnectionContext* context =0; |
|
685 TBool found = EFalse; |
|
686 for (TInt i=0; i < iConnectionCtxArray.Count() && !found; i++) |
|
687 { |
|
688 if ( iConnectionCtxArray[i]->Connection()->IapId() == aIapId ) |
|
689 { |
|
690 context = iConnectionCtxArray[i]; |
|
691 found = ETrue; |
|
692 } |
|
693 } |
|
694 return context; |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // CSIPIetfProfileAgent::ProvideContextL |
|
699 // (other items were commented in a header). |
|
700 // ----------------------------------------------------------------------------- |
|
701 // |
|
702 CSIPIetfProfileContext& CSIPIetfProfileAgent::ProvideProfileContextL( |
|
703 CSIPConcreteProfile& aProfile) |
|
704 { |
|
705 PROFILE_DEBUG3("CSIPIetfProfileAgent::ProvideProfileContextL", |
|
706 aProfile.Id()) |
|
707 |
|
708 CSIPIetfConnectionContext* connContext = FindConnectionContext(aProfile); |
|
709 if (!connContext) |
|
710 { |
|
711 // Must create connection first |
|
712 connContext = CSIPIetfConnectionContext::NewLC(); |
|
713 |
|
714 // If there's several profiles using the same iap, other ones need |
|
715 // new csip instance as once csip instance cannot contain several |
|
716 // csipconnections having the same iap id. |
|
717 // |
|
718 TUint32 iapId( aProfile.IapId() ); |
|
719 CSIPConnection* connection = NULL; |
|
720 if ( FindConnectionContext( iapId ) ) |
|
721 { |
|
722 CSIP& sip = connContext->CreateSipL( *this, *this ); |
|
723 connection = CSIPConnection::NewL( sip, iapId, *connContext ); |
|
724 } |
|
725 else |
|
726 { |
|
727 connection = CSIPConnection::NewL( *iSIP, iapId, *connContext ); |
|
728 } |
|
729 connContext->SetConnection( connection ); |
|
730 |
|
731 // Connection should be set before setting user |
|
732 connContext->SetConnectionUserL( aProfile ); |
|
733 |
|
734 User::LeaveIfError( iConnectionCtxArray.Append( connContext ) ); |
|
735 CleanupStack::Pop();//connContext |
|
736 } |
|
737 CSIPIetfProfileContext* profilectx = CSIPIetfProfileContext::NewLC( |
|
738 *iSIP, *connContext, *this, |
|
739 *iInit, aProfile, iDeltaTimer,*iConfigExtension); |
|
740 connContext->AddProfileContextL(profilectx); |
|
741 CleanupStack::Pop();//profilectx |
|
742 return *profilectx; |
|
743 } |
|
744 |
|
745 // ----------------------------------------------------------------------------- |
|
746 // CSIPIetfProfileAgent::ProvideContextL |
|
747 // (other items were commented in a header). |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 void CSIPIetfProfileAgent::CleanIdleConnectionContexts() |
|
751 { |
|
752 CSIPIetfConnectionContext* context = 0; |
|
753 |
|
754 for (TInt i=iConnectionCtxArray.Count()-1; i>= 0;) |
|
755 { |
|
756 iConnectionCtxArray[i]->CleanIdleContexts(); |
|
757 if (iConnectionCtxArray[i]->IsIdle()) |
|
758 { |
|
759 PROFILE_DEBUG1("CSIPIetfProfileAgent::CleanIdleConnectionContexts,\ |
|
760 ConnectionContext removed") |
|
761 context = iConnectionCtxArray[i]; |
|
762 iConnectionCtxArray.Remove(i); |
|
763 delete context; |
|
764 context = NULL; |
|
765 } |
|
766 i--; |
|
767 } |
|
768 |
|
769 iConnectionCtxArray.Compress(); |
|
770 } |