|
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 : CSipConnectionMgr.cpp |
|
15 // Part of : ConnectionMgr |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "CSipConnectionMgr.h" |
|
22 #include "CSipConnection.h" |
|
23 #include "MTransactionFinder.h" |
|
24 #include "Lwtimer.h" |
|
25 #include "SipLogs.h" |
|
26 #include "CleanupResetAndDestroy.h" |
|
27 #include "sipsigcomphandler.h" |
|
28 #include "sipsigcompnotintegrated.h" |
|
29 #include "CNetworkManager.h" |
|
30 #include "TSIPTransportParams.h" |
|
31 #include "sipsigcomphandlerinitparams.h" |
|
32 #include "NetworkInfo.h" |
|
33 #include "CNATTraversalNotIntegrated.h" |
|
34 #include "SipAssert.h" |
|
35 #include "cellulardatausagemonitor.h" |
|
36 #include <sipnattraversalcontroller.h> |
|
37 #include <sipnattraversalcontrollerinitparams.h> |
|
38 #include <sipsystemstatemonitor.h> |
|
39 |
|
40 const TUint KSIPMessageSlots = 32; |
|
41 |
|
42 const TInt CSipConnection::iConnectionOffset = |
|
43 _FOFF(CSipConnection, iConnectionLink); |
|
44 |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CSipConnectionMgr::NewL |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CSipConnectionMgr* CSipConnectionMgr::NewL( MTransactionFinder& aFinder, |
|
51 MServerTaFactory& aTaFactory, MTimerManager& aTimer, TUint aTOne, |
|
52 MConnectionStateObserver& aNetworkObserver ) |
|
53 { |
|
54 CSipConnectionMgr* self = NewLC( aFinder, aTaFactory, aTimer, |
|
55 aTOne, aNetworkObserver ); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CSipConnectionMgr::NewLC |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CSipConnectionMgr* CSipConnectionMgr::NewLC( MTransactionFinder& aFinder, |
|
65 MServerTaFactory& aTaFactory, MTimerManager& aTimer, TUint aTOne, |
|
66 MConnectionStateObserver& aNetworkObserver ) |
|
67 { |
|
68 CSipConnectionMgr* self = |
|
69 new (ELeave) CSipConnectionMgr( aFinder, aTaFactory, |
|
70 aTimer, aTOne, aNetworkObserver ); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CSipConnectionMgr::CSipConnectionMgr |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CSipConnectionMgr::CSipConnectionMgr( MTransactionFinder& aFinder, |
|
81 MServerTaFactory& aTaFactory, MTimerManager& aTimer, TUint aTOne, |
|
82 MConnectionStateObserver& aNetworkObserver ) : |
|
83 iFinder( &aFinder ), iTaFactory( &aTaFactory ), |
|
84 iTimer( &aTimer ), iTOne( aTOne ), |
|
85 iConnectionList( CSipConnection::iConnectionOffset ), |
|
86 iConnectionListIter( iConnectionList ) |
|
87 { |
|
88 iTUNetStatusObserver = &aNetworkObserver; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CSipConnectionMgr::ConstructL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CSipConnectionMgr::ConstructL() |
|
96 { |
|
97 User::LeaveIfError( iSocketServ.Connect( KSIPMessageSlots ) ); |
|
98 iNetworkManager = CNetworkManager::NewL(); |
|
99 iNetworkInfo = CNetworkInfo::NewL(*iNetworkManager); |
|
100 LoadSigCompL(); |
|
101 LoadNATTraversalL(); |
|
102 LoadSystemStateMonitorL(); |
|
103 iCellularDataUsageMonitor = CSipCellularDataUsageMonitor::NewL(*this); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CSipConnectionMgr::~CSipConnectionMgr |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 CSipConnectionMgr::~CSipConnectionMgr() |
|
111 { |
|
112 RemoveAllConnections(); |
|
113 iSocketServ.Close(); |
|
114 delete iSigCompController; |
|
115 delete iNATTraversal; |
|
116 delete iSystemStateMonitor; |
|
117 delete iCellularDataUsageMonitor; |
|
118 //Must delete iNetworkInfo before iNetworkManager |
|
119 delete iNetworkInfo; |
|
120 delete iNetworkManager; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CSipConnectionMgr::OpenL |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 CSIPConnection::TState CSipConnectionMgr::OpenL( |
|
128 const TSIPTransportParams& aParams) |
|
129 { |
|
130 TUint32 iapId = aParams.IapId(); |
|
131 |
|
132 __ASSERT_ALWAYS( iapId > 0, User::Leave(KErrBadName) ); |
|
133 |
|
134 CSipConnection* connection = 0; |
|
135 if ( ConnectionExists( iapId ) ) |
|
136 { |
|
137 connection = Connection( iapId ); |
|
138 } |
|
139 else |
|
140 { |
|
141 connection = CreateNewConnectionL( aParams ); |
|
142 } |
|
143 connection->IncreaseUserCount(); |
|
144 return connection->State(); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CSipConnectionMgr::IsOpen |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 TBool CSipConnectionMgr::IsOpen( const TSIPTransportParams& aParams ) |
|
152 { |
|
153 return ConnectionExists( aParams.IapId() ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CSipConnectionMgr::Close |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CSipConnectionMgr::Close( const TSIPTransportParams& aParams ) |
|
161 { |
|
162 TUint32 iapId = aParams.IapId(); |
|
163 |
|
164 if ( ConnectionExists( iapId ) ) |
|
165 { |
|
166 if ( Connection( iapId )->DecreaseUserCount( aParams ) == 0 ) |
|
167 { |
|
168 RemoveConnection( iapId ); |
|
169 } |
|
170 } |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CSipConnectionMgr::SetOptL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CSipConnectionMgr::SetOptL( |
|
178 const TSIPTransportParams& aParams, |
|
179 TUint aOptionName, |
|
180 TUint aOptionLevel, |
|
181 const TDesC8& aOption ) |
|
182 { |
|
183 __ASSERT_ALWAYS( aParams.OwnerId() > 0, User::Leave( KErrArgument ) ); |
|
184 TUint32 iapId = aParams.IapId(); |
|
185 if ( ConnectionExists( iapId ) ) |
|
186 { |
|
187 Connection( iapId )->SetOptL( |
|
188 aParams, aOptionName, aOptionLevel, aOption ); |
|
189 } |
|
190 else |
|
191 { |
|
192 User::Leave( KErrNotFound ); |
|
193 } |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CSipConnectionMgr::SetOptL |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CSipConnectionMgr::SetOptL( |
|
201 const TSIPTransportParams& aParams, |
|
202 TUint aOptionName, |
|
203 TUint aOptionLevel, |
|
204 TInt aOption ) |
|
205 { |
|
206 __ASSERT_ALWAYS( aParams.OwnerId() > 0, User::Leave( KErrArgument ) ); |
|
207 TUint32 iapId = aParams.IapId(); |
|
208 if ( ConnectionExists( iapId ) ) |
|
209 { |
|
210 Connection( iapId )->SetOptL( |
|
211 aParams, aOptionName, aOptionLevel, aOption ); |
|
212 } |
|
213 else |
|
214 { |
|
215 User::Leave( KErrNotFound ); |
|
216 } |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CSipConnectionMgr::SendL |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void CSipConnectionMgr::SendL( |
|
224 const TSIPTransportParams& aParams, |
|
225 CSIPRequest& aRequest, |
|
226 TBool aForceUDP, |
|
227 const CUri8* aOutboundProxy, |
|
228 const TInetAddr& aRemoteAddr, |
|
229 TRequestStatus& aStatus ) |
|
230 { |
|
231 TUint32 iapId = aParams.IapId(); |
|
232 if ( ConnectionExists( iapId ) ) |
|
233 { |
|
234 Connection( iapId )->SendL( aParams, |
|
235 aRequest, |
|
236 aForceUDP, |
|
237 aOutboundProxy, |
|
238 aRemoteAddr, |
|
239 aStatus ); |
|
240 } |
|
241 else |
|
242 { |
|
243 User::Leave( KErrNotFound ); |
|
244 } |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CSipConnectionMgr::SendL |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 void CSipConnectionMgr::SendL( |
|
252 const TSIPTransportParams& aParams, |
|
253 CSIPResponse& aResponse, |
|
254 TTransactionId aId, |
|
255 TRequestStatus& aStatus ) |
|
256 { |
|
257 TUint32 iapId = aParams.IapId(); |
|
258 if ( ConnectionExists( iapId ) ) |
|
259 { |
|
260 Connection( iapId )->SendL( aParams, aResponse, aId, aStatus ); |
|
261 } |
|
262 else |
|
263 { |
|
264 User::Leave( KErrNotFound ); |
|
265 } |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CSipConnectionMgr::CancelSend |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 TInt CSipConnectionMgr::CancelSend( TRequestStatus &aStatus ) |
|
273 { |
|
274 CSipConnection* connection = 0; |
|
275 TInt ret( KErrNotFound ); |
|
276 iConnectionListIter.SetToFirst(); |
|
277 while ( ( connection = iConnectionListIter++ ) != 0 && |
|
278 ( ret == KErrNotFound ) ) |
|
279 { |
|
280 ret = connection->CancelSend( aStatus ); |
|
281 } |
|
282 return ret; |
|
283 } |
|
284 |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CSipConnectionMgr::CancelResponseSend |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 TInt CSipConnectionMgr::CancelResponseSend( |
|
291 TTransactionId aId, |
|
292 TBool aCancelAlso2xxResponses ) |
|
293 { |
|
294 CSipConnection* connection = 0; |
|
295 TInt ret( KErrNotFound ); |
|
296 iConnectionListIter.SetToFirst(); |
|
297 while ( ( connection = iConnectionListIter++ ) != 0 && |
|
298 ( ret == KErrNotFound ) ) |
|
299 { |
|
300 ret = connection->CancelResponseSend( aId, aCancelAlso2xxResponses ); |
|
301 } |
|
302 return ret; |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CSipConnectionMgr::TcpDisconnect |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void CSipConnectionMgr::TcpDisconnect( |
|
310 const TSIPTransportParams& aParams, |
|
311 const TInetAddr& aRemoteAddress ) |
|
312 { |
|
313 TUint32 iapId = aParams.IapId(); |
|
314 if ( ConnectionExists( iapId ) ) |
|
315 { |
|
316 Connection( iapId )->TcpDisconnect( aParams, aRemoteAddress ); |
|
317 } |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CSipConnectionMgr::FreeResources |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 void CSipConnectionMgr::FreeResources( |
|
325 MSIPNATBindingObserver& aSIPNATBindingObserver ) |
|
326 { |
|
327 CSipConnection* connection = 0; |
|
328 iConnectionListIter.SetToFirst(); |
|
329 while ( (connection = iConnectionListIter++) != 0 ) |
|
330 { |
|
331 connection->FreeResources( aSIPNATBindingObserver ); |
|
332 } |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CSipConnectionMgr::GetByURIL |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 void CSipConnectionMgr::GetByURIL( |
|
340 const CURIContainer& aURI, |
|
341 RPointerArray<MSIPResolvingResult>& aResult, |
|
342 const TSIPTransportParams& aParams, |
|
343 MSIPServerResolverObserver* aObserver ) |
|
344 { |
|
345 TUint32 iapId = aParams.IapId(); |
|
346 if ( ConnectionExists( iapId ) ) |
|
347 { |
|
348 Connection( iapId )->GetByURIL( aParams, aURI, aResult, aObserver ); |
|
349 } |
|
350 else |
|
351 { |
|
352 User::Leave( KErrNotReady ); |
|
353 } |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CSipConnectionMgr::CancelGetByUri |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void CSipConnectionMgr::CancelGetByUri( |
|
361 MSIPServerResolverObserver* aObserver ) |
|
362 { |
|
363 CSipConnection* connection = 0; |
|
364 iConnectionListIter.SetToFirst(); |
|
365 while ( (connection = iConnectionListIter++) != 0 ) |
|
366 { |
|
367 connection->CancelGetByUri( aObserver ); |
|
368 } |
|
369 } |
|
370 |
|
371 // ----------------------------------------------------------------------------- |
|
372 // CSipConnectionMgr::IsSupported |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 TBool CSipConnectionMgr::IsSupported() const |
|
376 { |
|
377 return iSigCompController->IsSupported(); |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CSipConnectionMgr::CreateCompartmentL |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 TUint32 CSipConnectionMgr::CreateCompartmentL( |
|
385 TUint32 aIapId ) |
|
386 { |
|
387 __ASSERT_ALWAYS( iSigCompController->IsSupported(), |
|
388 User::Leave( KErrNotSupported ) ); |
|
389 |
|
390 return iSigCompController->CreateCompartmentL( aIapId ); |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CSipConnectionMgr::RemoveCompartment |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 void CSipConnectionMgr::RemoveCompartment( TUint32 aCompartmentId ) |
|
398 { |
|
399 if ( iSigCompController->IsSupported() ) |
|
400 { |
|
401 iSigCompController->RemoveCompartment( aCompartmentId ); |
|
402 } |
|
403 } |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // CSipConnectionMgr::CompartmentCount |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 TInt CSipConnectionMgr::CompartmentCount() |
|
410 { |
|
411 return iSigCompController->CompartmentCount(); |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // CSipConnectionMgr::SendFailedL |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 void CSipConnectionMgr::SendFailedL( TUint32 aCompartmentId ) |
|
419 { |
|
420 iSigCompController->SendFailedL( aCompartmentId ); |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CSipConnectionMgr::Match |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 TBool CSipConnectionMgr::Match( const TDesC8& aAddress ) |
|
428 { |
|
429 CSipConnection* connection = 0; |
|
430 iConnectionListIter.SetToFirst(); |
|
431 while ( ( connection = iConnectionListIter++ ) != 0 ) |
|
432 { |
|
433 if ( connection->Match( aAddress ) ) |
|
434 { |
|
435 return ETrue; |
|
436 } |
|
437 } |
|
438 return EFalse; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CSipConnectionMgr::IsSystemStarted |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 TBool CSipConnectionMgr::IsSystemStarted() const |
|
446 { |
|
447 return ( iSystemState == CSipSystemStateMonitor::ESystemReady ); |
|
448 } |
|
449 |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CSipConnectionMgr::Destroy |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 void CSipConnectionMgr::Destroy( TUint32 aIapId ) |
|
456 { |
|
457 RemoveConnection( aIapId ); |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CSipConnectionMgr::IsCellularDataUsageAllowed |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 |
|
465 TBool CSipConnectionMgr:: IsCellularDataUsageAllowed() const |
|
466 { |
|
467 |
|
468 TBool val = (MSipCellularDataUsageObserver::EDataUsageAllowed == iCellularDataUsageMonitor->CellularUsageStatus()); |
|
469 __SIP_INT_LOG1( "CSipConnectionMgr::IsCellularDataUsageAllowed, return value", val ) |
|
470 return val; |
|
471 } |
|
472 |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // CSipConnectionMgr::ReserveTransportL |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 void CSipConnectionMgr::ReserveTransportL( |
|
479 TSIPTransportParams& aTransportParams, |
|
480 TUint aLocalSendPort, |
|
481 TUint aLocalReceivePort, |
|
482 const TInetAddr& aRemoteAddr, |
|
483 TUint aRemoteSendPort ) |
|
484 { |
|
485 TUint32 iapId = aTransportParams.IapId(); |
|
486 if ( ConnectionExists( iapId ) ) |
|
487 { |
|
488 // Old transport params are possibly used (if tp id is not default) |
|
489 // for mapping two related transports together. This is for the IPSec |
|
490 // need where two records are sharing the same listening port |
|
491 TSIPTransportParams oldTransportParams( aTransportParams ); |
|
492 |
|
493 aTransportParams.SetTransportId( CreateTransportId() ); |
|
494 |
|
495 CSipConnection* con = Connection( iapId ); |
|
496 TRAPD( err, con->ReserveTransportL( oldTransportParams, |
|
497 aTransportParams, |
|
498 aLocalSendPort, |
|
499 aLocalReceivePort, |
|
500 aRemoteAddr, |
|
501 aRemoteSendPort ) ); |
|
502 if ( err ) |
|
503 { |
|
504 TInt ignored( 0 ); |
|
505 con->RemoveReservedTransport( aTransportParams.TransportId(), |
|
506 0, |
|
507 ignored ); |
|
508 User::Leave( err ); |
|
509 } |
|
510 } |
|
511 else |
|
512 { |
|
513 User::Leave( KErrNotFound ); |
|
514 } |
|
515 } |
|
516 |
|
517 // ----------------------------------------------------------------------------- |
|
518 // CSipConnectionMgr::CreateTLSTransportL |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 void CSipConnectionMgr::CreateTLSTransportL( |
|
522 TSIPTransportParams& aTransportParams ) |
|
523 { |
|
524 TUint32 iapId = aTransportParams.IapId(); |
|
525 if ( ConnectionExists( iapId ) ) |
|
526 { |
|
527 aTransportParams.SetTransportId( CreateTransportId() ); |
|
528 |
|
529 CSipConnection* con = Connection( iapId ); |
|
530 TRAPD( err, con->ReserveTLSTransportL( aTransportParams ) ); |
|
531 if ( err ) |
|
532 { |
|
533 TInt ignored( 0 ); |
|
534 con->RemoveReservedTransport( aTransportParams.TransportId(), |
|
535 0, |
|
536 ignored ); |
|
537 User::Leave( err ); |
|
538 } |
|
539 } |
|
540 else |
|
541 { |
|
542 User::Leave( KErrNotFound ); |
|
543 } |
|
544 } |
|
545 |
|
546 // ----------------------------------------------------------------------------- |
|
547 // CSipConnectionMgr::RemoveTransport |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 void CSipConnectionMgr::RemoveTransport( TUint32 aTransportId ) |
|
551 { |
|
552 RemoveTransport( aTransportId, 0 ); |
|
553 } |
|
554 |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CSipConnectionMgr::RemoveTransport |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 TInt CSipConnectionMgr::RemoveTransport( |
|
560 TUint32 aTransportId, |
|
561 MSIPTransportRemovalObserver* aRemovalObserver ) |
|
562 { |
|
563 TInt numAsyncRemovals( 0 ); |
|
564 |
|
565 if ( aTransportId == 0 ) |
|
566 { |
|
567 return numAsyncRemovals; |
|
568 } |
|
569 CSipConnection* connection = 0; |
|
570 iConnectionListIter.SetToFirst(); |
|
571 TBool removed( EFalse ); |
|
572 while ( ( connection = iConnectionListIter++ ) != 0 && !removed ) |
|
573 { |
|
574 removed = connection->RemoveReservedTransport( aTransportId, |
|
575 aRemovalObserver, |
|
576 numAsyncRemovals ); |
|
577 } |
|
578 return numAsyncRemovals; |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CSipConnectionMgr::GetLocalAddress |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 TInt CSipConnectionMgr::GetLocalAddress( TUint32 aIapId, TInetAddr& aAddr ) |
|
586 { |
|
587 if ( ConnectionExists( aIapId ) ) |
|
588 { |
|
589 return Connection( aIapId )->GetLocalAddress( aAddr ); |
|
590 } |
|
591 return KErrNotFound; |
|
592 } |
|
593 |
|
594 // ----------------------------------------------------------------------------- |
|
595 // CSipConnectionMgr::SystemVariableUpdated |
|
596 // ----------------------------------------------------------------------------- |
|
597 // |
|
598 void CSipConnectionMgr::SystemVariableUpdated( |
|
599 CSipSystemStateMonitor::TSystemVariable aVariable, |
|
600 TInt /*aObjectId*/, |
|
601 TInt aValue ) |
|
602 { |
|
603 __SIP_INT_LOG1( "CSipConnectionMgr::SystemVariableUpdated variable", |
|
604 aVariable ) |
|
605 |
|
606 __SIP_INT_LOG1( "CSipConnectionMgr::SystemVariableUpdated value", |
|
607 aValue ) |
|
608 |
|
609 if ( aVariable == CSipSystemStateMonitor::ESystemState && |
|
610 aValue == CSipSystemStateMonitor::ESystemReady && |
|
611 iSystemState != CSipSystemStateMonitor::ESystemReady ) |
|
612 { |
|
613 iSystemState = CSipSystemStateMonitor::ESystemReady; |
|
614 |
|
615 CSipConnection* connection = 0; |
|
616 iConnectionListIter.SetToFirst(); |
|
617 while ( ( connection = iConnectionListIter++ ) != 0 ) |
|
618 { |
|
619 connection->SystemStarted(); |
|
620 } |
|
621 } |
|
622 } |
|
623 |
|
624 // ----------------------------------------------------------------------------- |
|
625 // CSipConnectionMgr::CellularDataUsageChangedL |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 |
|
629 void CSipConnectionMgr::CellularDataUsageChangedL(MSipCellularDataUsageObserver::TCellularDataUsageStatus aStatus) |
|
630 { |
|
631 //First the Status must be retrived from the Monitor. |
|
632 //Then, if the Status is to be allowed only then the below code must execute. |
|
633 // Status check must typically happen by using CSipCellularDataUsageMonitor::CellularUsageStatus() |
|
634 // and the value must be EDataUsageAllowed. |
|
635 if(MSipCellularDataUsageObserver::EDataUsageAllowed == aStatus) |
|
636 { |
|
637 __SIP_LOG( "CSipConnectionMgr::CellularDataUsageChangedL(), Notified with CellularUsage Allowed" ) |
|
638 |
|
639 CSipConnection* connection = 0; |
|
640 iConnectionListIter.SetToFirst(); |
|
641 while ( ( connection = iConnectionListIter++ ) != 0 ) |
|
642 { |
|
643 connection->CellularUsageAllowed(); |
|
644 } |
|
645 } |
|
646 } |
|
647 // ----------------------------------------------------------------------------- |
|
648 // CSipConnectionMgr::CreateNewConnectionL |
|
649 // ----------------------------------------------------------------------------- |
|
650 // |
|
651 CSipConnection* CSipConnectionMgr::CreateNewConnectionL( |
|
652 const TSIPTransportParams& aParams ) |
|
653 { |
|
654 CSipConnection* connection = |
|
655 CSipConnection::NewLC( *iFinder, *iTaFactory, *iTimer, iTOne, |
|
656 aParams, iSocketServ, *iSigCompController, |
|
657 *iTUNetStatusObserver, *iNetworkManager, *this, |
|
658 *iNetworkInfo, *iNATTraversal ); |
|
659 CleanupStack::Pop( connection ); |
|
660 iConnectionList.AddLast( *connection ); |
|
661 return connection; |
|
662 } |
|
663 |
|
664 // ----------------------------------------------------------------------------- |
|
665 // CSipConnectionMgr::RemoveConnection |
|
666 // ----------------------------------------------------------------------------- |
|
667 // |
|
668 void CSipConnectionMgr::RemoveConnection( TUint32 aIapId ) |
|
669 { |
|
670 CSipConnection* connection = Connection( aIapId ); |
|
671 if ( connection ) |
|
672 { |
|
673 iConnectionList.Remove( *connection ); |
|
674 delete connection; |
|
675 } |
|
676 } |
|
677 |
|
678 // ----------------------------------------------------------------------------- |
|
679 // CSipConnectionMgr::ConnectionExists |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 TBool CSipConnectionMgr::ConnectionExists( TUint32 aIapId ) |
|
683 { |
|
684 return Connection( aIapId ) != 0; |
|
685 } |
|
686 |
|
687 // ----------------------------------------------------------------------------- |
|
688 // CSipConnectionMgr::Connection |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 CSipConnection* CSipConnectionMgr::Connection( TUint32 aIapId ) |
|
692 { |
|
693 CSipConnection* connection = 0; |
|
694 iConnectionListIter.SetToFirst(); |
|
695 while ( ( connection = iConnectionListIter++ ) != 0 ) |
|
696 { |
|
697 if ( connection->Handle( aIapId ) ) |
|
698 { |
|
699 return connection; |
|
700 } |
|
701 } |
|
702 return NULL; |
|
703 } |
|
704 |
|
705 // ----------------------------------------------------------------------------- |
|
706 // CSipConnectionMgr::RemoveAllConnections |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 void CSipConnectionMgr::RemoveAllConnections() |
|
710 { |
|
711 CSipConnection* connection = 0; |
|
712 iConnectionListIter.SetToFirst(); |
|
713 while ( ( connection = iConnectionListIter++ ) != 0 ) |
|
714 { |
|
715 iConnectionList.Remove( *connection ); |
|
716 delete connection; |
|
717 } |
|
718 } |
|
719 |
|
720 // ----------------------------------------------------------------------------- |
|
721 // CSipConnectionMgr::CreateTransportId |
|
722 // ----------------------------------------------------------------------------- |
|
723 // |
|
724 TUint32 CSipConnectionMgr::CreateTransportId() |
|
725 { |
|
726 if ( iTransportIdCounter < KMaxTUint32 ) |
|
727 { |
|
728 iTransportIdCounter++; |
|
729 } |
|
730 else |
|
731 { |
|
732 iTransportIdCounter = 1; |
|
733 } |
|
734 return iTransportIdCounter; |
|
735 } |
|
736 |
|
737 // ----------------------------------------------------------------------------- |
|
738 // CSipConnectionMgr::LoadSigCompL |
|
739 // ----------------------------------------------------------------------------- |
|
740 // |
|
741 void CSipConnectionMgr::LoadSigCompL() |
|
742 { |
|
743 TEComResolverParams resolverParams; |
|
744 RImplInfoPtrArray infoArray; |
|
745 REComSession::ListImplementationsL( KSIPSigCompInterfaceUid, |
|
746 infoArray ); |
|
747 CleanupResetAndDestroyPushL( infoArray ); |
|
748 |
|
749 if ( infoArray.Count() > 0 && infoArray[ 0 ] ) |
|
750 { |
|
751 CImplementationInformation& info = *( infoArray[ 0 ] ); |
|
752 TSIPSigCompHandlerInitParams initparam( *this ); |
|
753 resolverParams.SetDataType( info.DataType() ); |
|
754 |
|
755 iSigCompController = |
|
756 reinterpret_cast< CSigCompHandler* >( |
|
757 REComSession::CreateImplementationL( |
|
758 KSIPSigCompInterfaceUid, |
|
759 _FOFF(CSigCompHandler,iInstanceKey), |
|
760 &initparam, |
|
761 resolverParams ) ); |
|
762 |
|
763 __SIP_DES8_LOG( "SigComp plugin loaded", info.DataType() ) |
|
764 } |
|
765 else |
|
766 { |
|
767 iSigCompController = CSigCompNotIntegrated::NewL(); |
|
768 __SIP_LOG( "SigComp plugin not loaded" ) |
|
769 } |
|
770 |
|
771 CleanupStack::PopAndDestroy( 1 ); // infoArray |
|
772 } |
|
773 |
|
774 // ----------------------------------------------------------------------------- |
|
775 // CSipConnectionMgr::LoadNATTraversalL |
|
776 // ----------------------------------------------------------------------------- |
|
777 // |
|
778 void CSipConnectionMgr::LoadNATTraversalL() |
|
779 { |
|
780 TEComResolverParams resolverParams; |
|
781 RImplInfoPtrArray infoArray; |
|
782 REComSession::ListImplementationsL( KSIPNATTraversalControllerIFUid, |
|
783 infoArray ); |
|
784 CleanupResetAndDestroyPushL( infoArray ); |
|
785 |
|
786 if ( infoArray.Count() > 0 && infoArray[ 0 ] ) |
|
787 { |
|
788 CImplementationInformation& info = *( infoArray[ 0 ] ); |
|
789 resolverParams.SetDataType( info.DataType() ); |
|
790 TSIPNATTraversalControllerInitParams initParams( iSocketServ ); |
|
791 |
|
792 iNATTraversal = |
|
793 reinterpret_cast< CSIPNATTraversalController* >( |
|
794 REComSession::CreateImplementationL( |
|
795 KSIPNATTraversalControllerIFUid, |
|
796 _FOFF( CSIPNATTraversalController, iInstanceKey ), |
|
797 &initParams, |
|
798 resolverParams ) ); |
|
799 |
|
800 __SIP_DES8_LOG( "NATTraversal plugin loaded", info.DataType() ) |
|
801 } |
|
802 else |
|
803 { |
|
804 iNATTraversal = CNATTraversalNotIntegrated::NewL(); |
|
805 __SIP_LOG( "NATTraversal plugin not loaded" ) |
|
806 } |
|
807 |
|
808 CleanupStack::PopAndDestroy( 1 ); // infoArray |
|
809 } |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // CSipConnectionMgr::LoadSystemStateMonitorL |
|
813 // ----------------------------------------------------------------------------- |
|
814 // |
|
815 void CSipConnectionMgr::LoadSystemStateMonitorL() |
|
816 { |
|
817 __ASSERT_ALWAYS( !iSystemStateMonitor, User::Leave( KErrAlreadyExists ) ); |
|
818 |
|
819 RImplInfoPtrArray infoArray; |
|
820 REComSession::ListImplementationsL( KSipSystemStateMonitorIfUid, |
|
821 infoArray ); |
|
822 |
|
823 if ( infoArray.Count() > 0 && infoArray[0] ) |
|
824 { |
|
825 // Create a specific plugin with its UID |
|
826 iSystemStateMonitor = reinterpret_cast<CSipSystemStateMonitor*>( |
|
827 REComSession::CreateImplementationL( |
|
828 infoArray[0]->ImplementationUid(), |
|
829 _FOFF(CSipSystemStateMonitor, iInstanceKey ) ) ); |
|
830 __SIP_LOG( "System State Monitor loaded" ) |
|
831 iSystemStateMonitor->StartMonitoringL( |
|
832 CSipSystemStateMonitor::ESystemState, 0, *this ); |
|
833 iSystemState = iSystemStateMonitor->State(); |
|
834 |
|
835 __SIP_INT_LOG1( "Current system state", iSystemState ) |
|
836 } |
|
837 else |
|
838 { |
|
839 __SIP_LOG( "System State Monitor not loaded" ) |
|
840 |
|
841 iSystemState = CSipSystemStateMonitor::ESystemReady; |
|
842 } |
|
843 infoArray.ResetAndDestroy(); |
|
844 } |
|
845 |
|
846 // ----------------------------------------------------------------------------- |
|
847 // CSipConnectionMgr::RefreshConnection |
|
848 // ----------------------------------------------------------------------------- |
|
849 // |
|
850 void CSipConnectionMgr::RefreshConnectionL(TUint32 aIapId) |
|
851 { |
|
852 iNetworkManager->RefreshConnectionL(aIapId); |
|
853 } |
|
854 |
|
855 // ----------------------------------------------------------------------------- |
|
856 // CSipConnectionMgr::ConnectionErrorL |
|
857 // ----------------------------------------------------------------------------- |
|
858 // |
|
859 TInt CSipConnectionMgr::ConnectionErrorL(TUint32 aIapId) |
|
860 { |
|
861 CSipConnection* conn = Connection(aIapId); |
|
862 __SIP_ASSERT_LEAVE(conn, KErrNotFound); |
|
863 return conn->ConnectionError(); |
|
864 } |
|
865 // End of file |