|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <badesca.h> |
|
22 #include "natfwpluginapi.h" |
|
23 #include "mnatfwconnectivityobserver.h" |
|
24 #include "natfwcandidatepair.h" |
|
25 #include "natfwcandidate.h" |
|
26 #include "natfwsession.h" |
|
27 #include "natfwstream.h" |
|
28 #include "mnatfwregistrationcontroller.h" |
|
29 #include <cnatfwsettingsapi.h> |
|
30 #include "natfwclientlogs.h" |
|
31 #include "cncmconnectionmultiplexer.h" |
|
32 #include "cnatfwasynccallback.h" |
|
33 |
|
34 const TUint KSendingActivationsNeeded = 2; |
|
35 |
|
36 const TUint KReceivingActivationsNeeded = 2; |
|
37 |
|
38 // ======== MEMBER FUNCTIONS ======== |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // CNATFWSession::CNATFWSession |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CNATFWSession::CNATFWSession( CNcmConnectionMultiplexer& aMultiplexer, |
|
45 MNATFWRegistrationController& aController, |
|
46 CNatFwAsyncCallback& aAsyncCallback, |
|
47 TUint32 aIapId ) |
|
48 : |
|
49 iIapId( aIapId ), |
|
50 iController( aController ), |
|
51 iMultiplexer( aMultiplexer ), |
|
52 iAsyncCallback( aAsyncCallback ), |
|
53 iServerConnectionState( EConnectionUnspecified ) |
|
54 { |
|
55 } |
|
56 |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CNATFWSession::ConstructL |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 void CNATFWSession::ConstructL( const TDesC8& aDomain ) |
|
63 { |
|
64 iDomain = aDomain.AllocL(); |
|
65 TUint startPort( 0 ); |
|
66 TUint endPort( 0 ); |
|
67 |
|
68 iNatSettings = CNATFWNatSettingsApi::NewL( aDomain ); |
|
69 |
|
70 iNatSettings->GetPortArea( startPort, endPort ); |
|
71 |
|
72 iSessionId = iMultiplexer.CreateSessionL( iIapId, startPort, endPort ); |
|
73 } |
|
74 |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CNATFWSession::NewL |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 CNATFWSession* CNATFWSession::NewL( CNcmConnectionMultiplexer& aMultiplexer, |
|
81 MNATFWRegistrationController& aController, |
|
82 CNatFwAsyncCallback& aAsyncCallback, |
|
83 const TDesC8& aDomain, |
|
84 TUint32 aIapId ) |
|
85 { |
|
86 CNATFWSession* self = |
|
87 CNATFWSession::NewLC( aMultiplexer, aController, aAsyncCallback, |
|
88 aDomain, aIapId ); |
|
89 CleanupStack::Pop( self ); |
|
90 return self; |
|
91 } |
|
92 |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // CNATFWSession::NewLC |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 CNATFWSession* CNATFWSession::NewLC( CNcmConnectionMultiplexer& aMultiplexer, |
|
99 MNATFWRegistrationController& aController, |
|
100 CNatFwAsyncCallback& aAsyncCallback, |
|
101 const TDesC8& aDomain, |
|
102 TUint32 aIapId ) |
|
103 { |
|
104 CNATFWSession* self = new ( ELeave ) CNATFWSession( aMultiplexer, |
|
105 aController, aAsyncCallback, aIapId ); |
|
106 CleanupStack::PushL( self ); |
|
107 self->ConstructL( aDomain ); |
|
108 return self; |
|
109 } |
|
110 |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // Destructor |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CNATFWSession::~CNATFWSession() |
|
117 { |
|
118 iSendingStatusCounts.Close(); |
|
119 iReceivingStatusCounts.Close(); |
|
120 iFetchCandidateQueue.Close(); |
|
121 iStreams.ResetAndDestroy(); |
|
122 delete iDomain; |
|
123 delete iPlugin; |
|
124 delete iNatSettings; |
|
125 |
|
126 REComSession::FinalClose(); |
|
127 |
|
128 TInt err = KErrNone; |
|
129 TRAP( err, iMultiplexer.RemoveSessionL( iSessionId ) ); |
|
130 __NATFWCLIENT_INT1("CNATFWSession::~CNATFWSession, ERR:", err ) |
|
131 } |
|
132 |
|
133 |
|
134 // Non-derived function |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // CNATFWSession::LoadPluginL() |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CNATFWSession::LoadPluginL( const CDesC8Array& aPlugins, |
|
141 TInt& aLoadedPluginInd ) |
|
142 { |
|
143 __NATFWCLIENT("CNATFWSession::LoadPluginL") |
|
144 __ASSERT_ALWAYS( aPlugins.Count(), User::Leave( KErrArgument ) ); |
|
145 |
|
146 CNATFWPluginApi::TNATFWPluginInitParams |
|
147 initParams( *this, iMultiplexer, *iDomain, iIapId ); |
|
148 |
|
149 TInt error( KErrNotFound ); |
|
150 TInt count( aPlugins.Count() ); |
|
151 TInt index( 0 ); |
|
152 |
|
153 delete iPlugin; |
|
154 iPlugin = NULL; |
|
155 |
|
156 while ( !iPlugin && index < count ) |
|
157 { |
|
158 TRAP( error, iPlugin = |
|
159 CNATFWPluginApi::NewL( aPlugins[index], initParams ) ); |
|
160 index++; |
|
161 } |
|
162 |
|
163 TInt ind( iStreams.Count() ); |
|
164 while ( ind-- ) |
|
165 { |
|
166 iStreams[ind]->SetProtocolPlugin( iPlugin ); |
|
167 } |
|
168 |
|
169 User::LeaveIfError( error ); |
|
170 aLoadedPluginInd = --index; |
|
171 |
|
172 RSocketServ* socketServ = NULL; |
|
173 TName connectionName; |
|
174 |
|
175 socketServ = iMultiplexer.GetSessionInfoL( iSessionId, connectionName ); |
|
176 iPlugin->ConnectServerL( *socketServ, connectionName ); |
|
177 iServerConnectionState = EConnectionInProgress; |
|
178 |
|
179 __NATFWCLIENT("CNATFWSession::LoadPluginL Exit") |
|
180 } |
|
181 |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CNATFWSession::FetchCandidateL |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 void CNATFWSession::FetchCandidateL( TUint aStreamId, TUint aAddrFamily ) |
|
188 { |
|
189 __ASSERT_ALWAYS( iServerConnectionState != EConnectionUnspecified, |
|
190 User::Leave( KErrNotReady ) ); |
|
191 __ASSERT_ALWAYS( iServerConnectionState != EConnectionFailed, |
|
192 User::Leave( KErrNotReady ) ); |
|
193 |
|
194 if ( iServerConnectionState == EConnectionConnected ) |
|
195 { |
|
196 StreamByIdL( aStreamId )->FetchCandidateL( aAddrFamily ); |
|
197 } |
|
198 else |
|
199 { |
|
200 TFetchingData data( aStreamId, 0, 0, aAddrFamily, EFalse ); |
|
201 iFetchCandidateQueue.InsertL( data, 0 ); |
|
202 } |
|
203 } |
|
204 |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CNATFWSession::FetchCandidatesL |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CNATFWSession::FetchCandidatesL( TUint aStreamId, TUint aCollectionId, |
|
211 TUint aComponentId, TUint aAddrFamily ) |
|
212 { |
|
213 __ASSERT_ALWAYS( iServerConnectionState != EConnectionUnspecified, |
|
214 User::Leave( KErrNotReady ) ); |
|
215 __ASSERT_ALWAYS( iServerConnectionState != EConnectionFailed, |
|
216 User::Leave( KErrNotReady ) ); |
|
217 |
|
218 if ( iServerConnectionState == EConnectionConnected ) |
|
219 { |
|
220 StreamByIdL( aStreamId )->FetchCandidatesL( |
|
221 aCollectionId, aComponentId, aAddrFamily ); |
|
222 } |
|
223 else |
|
224 { |
|
225 TFetchingData data( aStreamId, aCollectionId, |
|
226 aComponentId, aAddrFamily, ETrue ); |
|
227 |
|
228 iFetchCandidateQueue.InsertL( data, 0 ); |
|
229 } |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // CNATFWSession::SessionId |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 TUint CNATFWSession::SessionId() const |
|
237 { |
|
238 __NATFWCLIENT("CNATFWSession::SessionId") |
|
239 |
|
240 return iSessionId; |
|
241 } |
|
242 |
|
243 |
|
244 // --------------------------------------------------------------------------- |
|
245 // CNATFWSession::CreateStreamL |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 TUint CNATFWSession::CreateStreamL( |
|
249 TUint aProtocol, TInt aQoS ) |
|
250 { |
|
251 __NATFWCLIENT("CNATFWSession::CreateStreamL") |
|
252 |
|
253 CNATFWStream* stream = CNATFWStream::NewL( iController, iMultiplexer, |
|
254 iAsyncCallback, *this, aProtocol, aQoS ); |
|
255 CleanupStack::PushL( stream ); |
|
256 |
|
257 iStreams.AppendL( stream ); |
|
258 stream->SetProtocolPlugin( iPlugin ); |
|
259 |
|
260 CleanupStack::Pop( stream ); |
|
261 return stream->StreamId(); |
|
262 } |
|
263 |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // CNATFWSession::SetRoleL |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CNATFWSession::SetRoleL( TNATFWIceRole aRole ) |
|
270 { |
|
271 __NATFWCLIENT("CNATFWSession::SetRoleL") |
|
272 |
|
273 iPlugin->SetRoleL( aRole ); |
|
274 } |
|
275 |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // CNATFWSession::PerformConnectivityChecksL |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 void CNATFWSession::PerformConnectivityChecksL( |
|
282 RPointerArray<CNATFWCandidate>& aRemoteCandidates ) |
|
283 { |
|
284 __NATFWCLIENT("CNATFWSession::PerformConnectivityChecksL") |
|
285 |
|
286 iPlugin->PerformConnectivityChecksL( aRemoteCandidates ); |
|
287 } |
|
288 |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // CNATFWSession::UpdateIceProcessingL |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 void CNATFWSession::UpdateIceProcessingL( |
|
295 RPointerArray<CNATFWCandidatePair>& aPeerSelectedPairs ) |
|
296 { |
|
297 iPlugin->UpdateIceProcessingL( aPeerSelectedPairs ); |
|
298 } |
|
299 |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // CNATFWSession::UpdateIceProcessingL |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 void CNATFWSession::UpdateIceProcessingL( |
|
306 RPointerArray<CNATFWCandidate>& aRemoteCands ) |
|
307 { |
|
308 iPlugin->UpdateIceProcessingL( aRemoteCands ); |
|
309 } |
|
310 |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // CNATFWSession::CloseStream |
|
314 // --------------------------------------------------------------------------- |
|
315 // |
|
316 void CNATFWSession::CloseStreamL( TUint aStreamId ) |
|
317 { |
|
318 __NATFWCLIENT("CNATFWSession::CloseStreamL") |
|
319 |
|
320 CNATFWStream* stream = StreamByIdL( aStreamId ); |
|
321 iStreams.Remove( iStreams.FindL( stream ) ); |
|
322 delete stream; |
|
323 } |
|
324 |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // CNATFWSession::StreamById |
|
328 // --------------------------------------------------------------------------- |
|
329 // |
|
330 CNATFWStream* CNATFWSession::StreamById( TUint aStreamId ) |
|
331 { |
|
332 __NATFWCLIENT("CNATFWSession::StreamById") |
|
333 |
|
334 TInt ind( iStreams.Count() ); |
|
335 |
|
336 while ( ind-- ) |
|
337 { |
|
338 if ( iStreams[ind]->StreamId() == aStreamId ) |
|
339 { |
|
340 return iStreams[ind]; |
|
341 } |
|
342 } |
|
343 |
|
344 return NULL; |
|
345 } |
|
346 |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CNATFWSession::StreamByIdL |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 CNATFWStream* CNATFWSession::StreamByIdL( TUint aStreamId ) |
|
353 { |
|
354 __NATFWCLIENT("CNATFWSession::StreamByIdL") |
|
355 |
|
356 CNATFWStream* stream = StreamById( aStreamId ); |
|
357 if ( !stream ) |
|
358 { |
|
359 User::Leave( KErrNotFound ); |
|
360 } |
|
361 |
|
362 return stream; |
|
363 } |
|
364 |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // From class MNATFWPluginObserver. |
|
368 // CNATFWSession::Error |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void CNATFWSession::Error( const CNATFWPluginApi& /*aPlugin*/, |
|
372 TUint aStreamId, TInt aErrorCode ) |
|
373 { |
|
374 __NATFWCLIENT("CNATFWSession::Error") |
|
375 |
|
376 DoNotify( aStreamId, MNATFWConnectivityObserver::EGeneralError, |
|
377 aErrorCode, NULL ); |
|
378 } |
|
379 |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // From class MNATFWPluginObserver. |
|
383 // CNATFWSession::Notify |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 void CNATFWSession::Notify( const CNATFWPluginApi& /*aPlugin*/, |
|
387 TUint aStreamId, TNATFWPluginEvent aEvent, TInt aErrCode ) |
|
388 { |
|
389 __NATFWCLIENT("CNATFWSession::Notify") |
|
390 |
|
391 // Activation notify must be waited from both plugin |
|
392 // and mediastream before notifying NATFW client |
|
393 |
|
394 switch ( aEvent ) |
|
395 { |
|
396 case MNATFWPluginObserver::EServerConnected: |
|
397 { |
|
398 __NATFWCLIENT_INT1( |
|
399 "CNATFWSession::Notify EServerConnected, ERR:", aErrCode ) |
|
400 |
|
401 if ( KErrNone != aErrCode ) |
|
402 { |
|
403 iServerConnectionState = EConnectionFailed; |
|
404 } |
|
405 else |
|
406 { |
|
407 iServerConnectionState = EConnectionConnected; |
|
408 } |
|
409 HandleQueuedItems(); |
|
410 } |
|
411 break; |
|
412 |
|
413 case MNATFWPluginObserver::ESendingActivated: |
|
414 { |
|
415 __NATFWCLIENT_INT1( |
|
416 "CNATFWSession::Notify ESendingActivated, ERR:", aErrCode ) |
|
417 |
|
418 TInt index = iSendingStatusCounts.Count() - 1; |
|
419 TInt foundStreamInd( KErrNotFound ); |
|
420 |
|
421 while ( 0 <= index && KErrNotFound == foundStreamInd ) |
|
422 { |
|
423 if ( aStreamId == iSendingStatusCounts[index].iStreamId ) |
|
424 { |
|
425 foundStreamInd = index; |
|
426 |
|
427 if ( KErrNone != aErrCode ) |
|
428 { |
|
429 iSendingStatusCounts[foundStreamInd].iErrorOccurred |
|
430 = ETrue; |
|
431 } |
|
432 |
|
433 iSendingStatusCounts[foundStreamInd].iActivatedCount++; |
|
434 } |
|
435 |
|
436 index--; |
|
437 } |
|
438 |
|
439 if ( KErrNotFound != foundStreamInd ) |
|
440 { |
|
441 if ( KSendingActivationsNeeded == |
|
442 iSendingStatusCounts[foundStreamInd].iActivatedCount ) |
|
443 { |
|
444 // The second notify for current stream's sending |
|
445 // activation has occurred so NATFW Stream can be |
|
446 // notified |
|
447 CNATFWStream* stream = StreamById( aStreamId ); |
|
448 if ( stream ) |
|
449 { |
|
450 if ( iSendingStatusCounts[foundStreamInd]. |
|
451 iErrorOccurred ) |
|
452 { |
|
453 // Reset the error occurred flag |
|
454 iSendingStatusCounts[foundStreamInd].iErrorOccurred |
|
455 = EFalse; |
|
456 // Do notification with error code |
|
457 stream->Notify( iSessionId, aStreamId, |
|
458 MNcmConnectionMultiplexerObserver:: |
|
459 ESendingActivated, KErrGeneral ); |
|
460 } |
|
461 else |
|
462 { |
|
463 stream->Notify( iSessionId, aStreamId, |
|
464 MNcmConnectionMultiplexerObserver:: |
|
465 ESendingActivated, KErrNone ); |
|
466 } |
|
467 } |
|
468 } |
|
469 } |
|
470 else |
|
471 { |
|
472 // The first notify for stream's sending activation has |
|
473 // occurred so store stream's status data in array |
|
474 TStatusCounter sendingActivated; |
|
475 sendingActivated.iActivatedCount++; |
|
476 sendingActivated.iStreamId = aStreamId; |
|
477 |
|
478 if ( KErrNone != aErrCode ) |
|
479 { |
|
480 sendingActivated.iErrorOccurred = ETrue; |
|
481 } |
|
482 |
|
483 iSendingStatusCounts.Append( sendingActivated ); |
|
484 } |
|
485 } |
|
486 break; |
|
487 |
|
488 case MNATFWPluginObserver::ESendingDeactivated: |
|
489 { |
|
490 __NATFWCLIENT_INT1( |
|
491 "CNATFWSession::Notify ESendingDeactivated, ERR:", aErrCode ) |
|
492 |
|
493 TInt index = iSendingStatusCounts.Count() - 1; |
|
494 TInt foundStreamInd( KErrNotFound ); |
|
495 |
|
496 while ( 0 <= index && KErrNotFound == foundStreamInd ) |
|
497 { |
|
498 if ( aStreamId == iSendingStatusCounts[index].iStreamId && |
|
499 iSendingStatusCounts[index].iActivatedCount != 0 ) |
|
500 { |
|
501 foundStreamInd = index; |
|
502 |
|
503 if ( aErrCode != KErrNone ) |
|
504 { |
|
505 iSendingStatusCounts[foundStreamInd].iErrorOccurred |
|
506 = ETrue; |
|
507 } |
|
508 |
|
509 iSendingStatusCounts[foundStreamInd].iActivatedCount--; |
|
510 } |
|
511 |
|
512 index--; |
|
513 } |
|
514 |
|
515 if ( KErrNotFound != foundStreamInd ) |
|
516 { |
|
517 if ( 0 == iSendingStatusCounts[foundStreamInd]. |
|
518 iActivatedCount ) |
|
519 { |
|
520 CNATFWStream* stream = StreamById( aStreamId ); |
|
521 if ( stream ) |
|
522 { |
|
523 if ( iSendingStatusCounts[foundStreamInd]. |
|
524 iErrorOccurred ) |
|
525 { |
|
526 // Reset the error occurred flag |
|
527 iSendingStatusCounts[foundStreamInd].iErrorOccurred |
|
528 = EFalse; |
|
529 // Do notification with error code |
|
530 stream->Notify( iSessionId, aStreamId, |
|
531 MNcmConnectionMultiplexerObserver:: |
|
532 ESendingDeactivated, KErrGeneral ); |
|
533 } |
|
534 else |
|
535 { |
|
536 stream->Notify( iSessionId, aStreamId, |
|
537 MNcmConnectionMultiplexerObserver:: |
|
538 ESendingDeactivated, KErrNone ); |
|
539 } |
|
540 } |
|
541 } |
|
542 } |
|
543 } |
|
544 break; |
|
545 |
|
546 case MNATFWPluginObserver::EReceivingActivated: |
|
547 { |
|
548 __NATFWCLIENT_INT1( |
|
549 "CNATFWSession::Notify EReceivingActivated, ERR:", aErrCode ) |
|
550 |
|
551 TInt index = iReceivingStatusCounts.Count() - 1; |
|
552 TInt foundStreamInd( KErrNotFound ); |
|
553 |
|
554 while ( 0 <= index && KErrNotFound == foundStreamInd ) |
|
555 { |
|
556 if ( aStreamId == iReceivingStatusCounts[index].iStreamId ) |
|
557 { |
|
558 foundStreamInd = index; |
|
559 |
|
560 if ( KErrNone != aErrCode ) |
|
561 { |
|
562 iReceivingStatusCounts[foundStreamInd].iErrorOccurred |
|
563 = ETrue; |
|
564 } |
|
565 |
|
566 iReceivingStatusCounts[foundStreamInd].iActivatedCount++; |
|
567 } |
|
568 |
|
569 index--; |
|
570 } |
|
571 |
|
572 if ( KErrNotFound != foundStreamInd ) |
|
573 { |
|
574 if ( KReceivingActivationsNeeded == |
|
575 iReceivingStatusCounts[foundStreamInd].iActivatedCount ) |
|
576 { |
|
577 // The second notify for current stream's receiving |
|
578 // activation has occurred so NATFW Stream can be |
|
579 // notified |
|
580 CNATFWStream* stream = StreamById( aStreamId ); |
|
581 if ( stream ) |
|
582 { |
|
583 if ( iReceivingStatusCounts[foundStreamInd]. |
|
584 iErrorOccurred ) |
|
585 { |
|
586 // Reset the error occurred flag |
|
587 iReceivingStatusCounts[foundStreamInd].iErrorOccurred |
|
588 = EFalse; |
|
589 // Do notification with error code |
|
590 stream->Notify( iSessionId, aStreamId, |
|
591 MNcmConnectionMultiplexerObserver:: |
|
592 EReceivingActivated, KErrGeneral ); |
|
593 } |
|
594 else |
|
595 { |
|
596 stream->Notify( iSessionId, aStreamId, |
|
597 MNcmConnectionMultiplexerObserver:: |
|
598 EReceivingActivated, KErrNone ); |
|
599 } |
|
600 } |
|
601 } |
|
602 } |
|
603 else |
|
604 { |
|
605 // The first notify for stream's receiving activation has |
|
606 // occurred so store stream's status data in array |
|
607 TStatusCounter receivingActivated; |
|
608 receivingActivated.iActivatedCount++; |
|
609 receivingActivated.iStreamId = aStreamId; |
|
610 |
|
611 if ( KErrNone != aErrCode ) |
|
612 { |
|
613 receivingActivated.iErrorOccurred = ETrue; |
|
614 } |
|
615 |
|
616 iReceivingStatusCounts.Append( receivingActivated ); |
|
617 } |
|
618 } |
|
619 break; |
|
620 |
|
621 case MNATFWPluginObserver::EReceivingDeactivated: |
|
622 { |
|
623 __NATFWCLIENT_INT1( |
|
624 "CNATFWSession::Notify EReceivingDeactivated, ERR:", aErrCode ) |
|
625 |
|
626 TInt index = iReceivingStatusCounts.Count() - 1; |
|
627 TInt foundStreamInd( KErrNotFound ); |
|
628 |
|
629 while ( 0 <= index && KErrNotFound == foundStreamInd ) |
|
630 { |
|
631 if ( aStreamId == iReceivingStatusCounts[index].iStreamId && |
|
632 iReceivingStatusCounts[index].iActivatedCount != 0 ) |
|
633 { |
|
634 foundStreamInd = index; |
|
635 |
|
636 if ( aErrCode != KErrNone ) |
|
637 { |
|
638 iReceivingStatusCounts[foundStreamInd].iErrorOccurred |
|
639 = ETrue; |
|
640 } |
|
641 |
|
642 iReceivingStatusCounts[foundStreamInd].iActivatedCount--; |
|
643 } |
|
644 |
|
645 index--; |
|
646 } |
|
647 |
|
648 if ( KErrNotFound != foundStreamInd ) |
|
649 { |
|
650 if ( 0 == iReceivingStatusCounts[foundStreamInd]. |
|
651 iActivatedCount ) |
|
652 { |
|
653 CNATFWStream* stream = StreamById( aStreamId ); |
|
654 if ( stream ) |
|
655 { |
|
656 if ( iReceivingStatusCounts[foundStreamInd]. |
|
657 iErrorOccurred ) |
|
658 { |
|
659 // Reset the error occurred flag |
|
660 iReceivingStatusCounts[foundStreamInd].iErrorOccurred |
|
661 = EFalse; |
|
662 // Do notification with error code |
|
663 stream->Notify( iSessionId, aStreamId, |
|
664 MNcmConnectionMultiplexerObserver:: |
|
665 EReceivingDeactivated, KErrGeneral ); |
|
666 } |
|
667 else |
|
668 { |
|
669 stream->Notify( iSessionId, aStreamId, |
|
670 MNcmConnectionMultiplexerObserver:: |
|
671 EReceivingDeactivated, KErrNone ); |
|
672 } |
|
673 } |
|
674 } |
|
675 } |
|
676 } |
|
677 break; |
|
678 |
|
679 case MNATFWPluginObserver::EFetchingCompleted: |
|
680 { |
|
681 __NATFWCLIENT_INT1( |
|
682 "CNATFWSession::Notify EFetchingCompleted, ERR:", aErrCode ) |
|
683 |
|
684 DoNotify( aStreamId, MNATFWConnectivityObserver::EFetchingCompleted, |
|
685 aErrCode, NULL ); |
|
686 } |
|
687 break; |
|
688 |
|
689 case MNATFWPluginObserver::EConnChecksCompleted: |
|
690 { |
|
691 __NATFWCLIENT_INT1( |
|
692 "CNATFWSession::Notify EConnChecksCompleted, ERR:", aErrCode ) |
|
693 |
|
694 DoNotify( aStreamId, MNATFWConnectivityObserver::EConnChecksCompleted, |
|
695 aErrCode, NULL ); |
|
696 } |
|
697 break; |
|
698 |
|
699 default: |
|
700 { |
|
701 __NATFWCLIENT("CNATFWSession::Notify DEFAULT") |
|
702 ASSERT( EFalse ); |
|
703 } |
|
704 break; |
|
705 } |
|
706 |
|
707 __NATFWCLIENT("CNATFWSession::Notify Exit") |
|
708 } |
|
709 |
|
710 |
|
711 // --------------------------------------------------------------------------- |
|
712 // From class MNATFWPluginObserver. |
|
713 // CNATFWSession::NewCandidatePairFound |
|
714 // --------------------------------------------------------------------------- |
|
715 // |
|
716 void CNATFWSession::NewCandidatePairFound( |
|
717 const CNATFWPluginApi& /*aPlugin*/, |
|
718 CNATFWCandidatePair* aCandidatePair ) |
|
719 { |
|
720 __NATFWCLIENT("CNATFWSession::NewCandidatePairFound") |
|
721 |
|
722 if ( aCandidatePair ) |
|
723 { |
|
724 const_cast<CNATFWCandidate&>( |
|
725 aCandidatePair->RemoteCandidate() ).SetSessionId( iSessionId ); |
|
726 const_cast<CNATFWCandidate&>( |
|
727 aCandidatePair->LocalCandidate() ).SetSessionId( iSessionId ); |
|
728 DoNotify( aCandidatePair->LocalCandidate().StreamId(), |
|
729 MNATFWConnectivityObserver::ECandidatePairFound, |
|
730 KErrNone, aCandidatePair ); |
|
731 } |
|
732 else |
|
733 { |
|
734 __NATFWCLIENT("CNATFWSession::NewCandidatePairFound - NULL POINTER") |
|
735 } |
|
736 } |
|
737 |
|
738 |
|
739 // --------------------------------------------------------------------------- |
|
740 // From class MNATFWPluginObserver. |
|
741 // CNATFWSession::NewLocalCandidateFound |
|
742 // --------------------------------------------------------------------------- |
|
743 // |
|
744 void CNATFWSession::NewLocalCandidateFound( |
|
745 const CNATFWPluginApi& /*aPlugin*/, |
|
746 CNATFWCandidate* aCandidate ) |
|
747 { |
|
748 __NATFWCLIENT("CNATFWSession::NewLocalCandidateFound") |
|
749 |
|
750 if ( aCandidate ) |
|
751 { |
|
752 aCandidate->SetSessionId( iSessionId ); |
|
753 DoNotify( aCandidate->StreamId(), |
|
754 MNATFWConnectivityObserver::ELocalCandidateFound, |
|
755 KErrNone, aCandidate ); |
|
756 } |
|
757 else |
|
758 { |
|
759 __NATFWCLIENT("CNATFWSession::NewLocalCandidateFound - NULL POINTER") |
|
760 } |
|
761 } |
|
762 |
|
763 |
|
764 // --------------------------------------------------------------------------- |
|
765 // CNATFWSession::HandleQueuedItems |
|
766 // --------------------------------------------------------------------------- |
|
767 // |
|
768 void CNATFWSession::HandleQueuedItems() |
|
769 { |
|
770 __NATFWCLIENT("CNATFWSession::HandleQueuedItems - ENTRY") |
|
771 |
|
772 TInt index( iFetchCandidateQueue.Count() - 1 ); |
|
773 TUint streamId( 0 ); |
|
774 TUint collectionId( 0 ); |
|
775 TUint componentId( 0 ); |
|
776 TUint addrFamily( KAFUnspec ); |
|
777 TBool iceSpecific( EFalse ); |
|
778 |
|
779 while ( 0 <= index ) |
|
780 { |
|
781 streamId = iFetchCandidateQueue[index].iStreamId; |
|
782 collectionId = iFetchCandidateQueue[index].iCollectionId; |
|
783 componentId = iFetchCandidateQueue[index].iComponentId; |
|
784 addrFamily = iFetchCandidateQueue[index].iAddrFamily; |
|
785 iceSpecific = iFetchCandidateQueue[index].iICESpecific; |
|
786 iFetchCandidateQueue.Remove( index ); |
|
787 |
|
788 CNATFWStream* str( NULL ); |
|
789 str = StreamById( streamId ); |
|
790 |
|
791 TInt error( KErrNone ); |
|
792 if ( str ) |
|
793 { |
|
794 if( iceSpecific ) |
|
795 { |
|
796 TRAP( error, |
|
797 str->FetchCandidatesL( |
|
798 collectionId, componentId, addrFamily ) ); |
|
799 } |
|
800 else |
|
801 { |
|
802 TRAP( error, str->FetchCandidateL( addrFamily ) ); |
|
803 } |
|
804 } |
|
805 |
|
806 if ( KErrNone != error ) |
|
807 { |
|
808 DoNotify( streamId, MNATFWConnectivityObserver::EFetchingCompleted, |
|
809 error, NULL ); |
|
810 } |
|
811 |
|
812 --index; |
|
813 } |
|
814 |
|
815 __NATFWCLIENT("CNATFWSession::HandleQueuedItems - EXIT") |
|
816 } |
|
817 |
|
818 |
|
819 // --------------------------------------------------------------------------- |
|
820 // CNATFWSession::DoNotify |
|
821 // --------------------------------------------------------------------------- |
|
822 // |
|
823 void CNATFWSession::DoNotify( TUint aStreamId, |
|
824 MNATFWConnectivityObserver::TNATFWConnectivityEvent aEvent, |
|
825 TInt aErrCode, |
|
826 TAny* aEventData ) |
|
827 { |
|
828 CNatFwCallbackInfo::TFunction func = |
|
829 static_cast<CNatFwCallbackInfo::TFunction>( aEvent ); |
|
830 |
|
831 TRAP_IGNORE( iAsyncCallback.MakeCallbackL( iController, func, |
|
832 iSessionId, aStreamId, aErrCode, aEventData ) ) |
|
833 |
|
834 } |