|
1 /* |
|
2 * Copyright (c) 2008 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 <sipstrconsts.h> |
|
22 #include "mcesession.h" |
|
23 #include "mceinsession.h" |
|
24 #include "mcemanager.h" |
|
25 #include "mceinsessionobserver.h" |
|
26 #include "mcesessionobserver.h" |
|
27 #include "mcestreamobserver.h" |
|
28 #include "mcetransactionobserver.h" |
|
29 #include "mceintransactionobserver.h" |
|
30 #include "mcertpobserver.h" |
|
31 #include "mcefcmsgobserver.h" |
|
32 #include "mcetransactiondatacontainer.h" |
|
33 #include "mcefactory.h" |
|
34 #include "mceitcsender.h" |
|
35 #include "mcesessionreceiver.h" |
|
36 #include "mceclientserver.h" |
|
37 #include "mceevents.h" |
|
38 #include "mceserial.h" |
|
39 #include "mceitcsender.h" |
|
40 #include "mcesessionreceiver.h" |
|
41 #include "mce.h" |
|
42 #include "mcecomsession.h" |
|
43 #include "mcecommediasink.h" |
|
44 #include "mcecommediasource.h" |
|
45 #include "mcestreambundle.h" |
|
46 #include "mceclilogs.h" |
|
47 |
|
48 #define _FLAT_DATA static_cast<CMceComSession*>( iFlatData ) |
|
49 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
50 |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CMceSession::~CMceSession |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CMceSession::~CMceSession() |
|
60 { |
|
61 MCECLI_DEBUG("CMceSession::~CMceSession, Entry") |
|
62 |
|
63 //causes EMceItcClientCancelReceive |
|
64 delete iReceiver; |
|
65 iReceiver = NULL; |
|
66 |
|
67 if ( iManager && iFlatData ) |
|
68 { |
|
69 //causes EMceItcDeleteSession |
|
70 iManager->UnregisterSession( this ); |
|
71 } |
|
72 |
|
73 delete iFlatData; |
|
74 delete iSender; |
|
75 |
|
76 iMediaStreams.ResetAndDestroy(); |
|
77 iBundles.ResetAndDestroy(); |
|
78 |
|
79 MCECLI_DEBUG("CMceSession::~CMceSession, Exit") |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CMceSession::State |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 EXPORT_C CMceSession::TState CMceSession::State() const |
|
87 { |
|
88 return FLAT_DATA( iState ); |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CMceSession::GetSIPParams |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CMceSession::GetSIPParams( CDesC8Array*& aHeaders, |
|
96 HBufC8*& aContentType, |
|
97 CDesC8Array*& aContentHeaders ) |
|
98 { |
|
99 CDesC8Array* sipHeaders = FLAT_DATA( iSIPHeaders ); |
|
100 HBufC8* sipContentType = FLAT_DATA( iSIPContentType ); |
|
101 CDesC8Array* sipContentHeaders = FLAT_DATA( iSIPContentHeaders ); |
|
102 FLAT_DATA( iSIPHeaders ) = NULL; |
|
103 FLAT_DATA( iSIPContentType ) = NULL; |
|
104 FLAT_DATA( iSIPContentHeaders ) = NULL; |
|
105 aHeaders = sipHeaders; |
|
106 aContentType = sipContentType; |
|
107 aContentHeaders = sipContentHeaders; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CMceSession::SetSIPParams |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CMceSession::SetSIPParams( CDesC8Array* aHeaders, |
|
115 HBufC8* aContentType, |
|
116 CDesC8Array* aContentHeaders ) |
|
117 { |
|
118 delete FLAT_DATA( iSIPHeaders ); |
|
119 FLAT_DATA( iSIPHeaders ) = aHeaders; |
|
120 delete FLAT_DATA( iSIPContentType ); |
|
121 FLAT_DATA( iSIPContentType ) = aContentType; |
|
122 delete FLAT_DATA( iSIPContentHeaders ); |
|
123 FLAT_DATA( iSIPContentHeaders ) = aContentHeaders; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CMceSession::SIPParamsCleanup |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CMceSession::SIPParamsCleanup( TAny* aSession ) |
|
131 { |
|
132 if ( !aSession ) |
|
133 { |
|
134 return; |
|
135 } |
|
136 CMceSession* session = reinterpret_cast< CMceSession* >( aSession ); |
|
137 session->iFlatData->iSIPHeaders = 0; |
|
138 session->iFlatData->iSIPContentType = 0; |
|
139 session->iFlatData->iSIPContentHeaders = 0; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CMceSession::ConnectionActive |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C TBool CMceSession::ConnectionActive() const |
|
147 { |
|
148 return FLAT_DATA( iIsConnectionActive ); |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CMceSession::AddStreamL |
|
153 // If called from InternalizeL, iManager is NULL and don't initialize stream. |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CMceSession::AddStreamL( CMceMediaStream* aMediaStream ) |
|
157 { |
|
158 __ASSERT_ALWAYS( aMediaStream != NULL, User::Leave( KErrArgument ) ); |
|
159 __ASSERT_ALWAYS( iMediaStreams.Find( aMediaStream ) == KErrNotFound, |
|
160 User::Leave( KErrArgument ) ); |
|
161 __ASSERT_ALWAYS( !aMediaStream->BoundStream() || |
|
162 aMediaStream->Binder(), User::Leave( KErrArgument ) ); |
|
163 |
|
164 aMediaStream->AddedL(); |
|
165 |
|
166 if ( iManager && StreamInitializeCondition( *aMediaStream ) ) |
|
167 { |
|
168 // Initialize stream to get the supported codecs |
|
169 aMediaStream->InitializeL( iManager, *this ); |
|
170 } |
|
171 |
|
172 DoAddStreamL( aMediaStream ); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CMceSession::DoAddStreamL |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CMceSession::DoAddStreamL( CMceMediaStream* aMediaStream ) |
|
180 { |
|
181 iMediaStreams.AppendL( aMediaStream ); |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CMceSession::RemoveStreamL |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 EXPORT_C void CMceSession::RemoveStreamL( CMceMediaStream& aMediaStream ) |
|
189 { |
|
190 MCECLI_DEBUG("CMceSession::RemoveStreamL, Entry") |
|
191 |
|
192 __ASSERT_ALWAYS( State() == CMceSession::EIdle || |
|
193 State() == CMceSession::EIncoming || |
|
194 State() == CMceSession::EEstablished, |
|
195 User::Leave( KErrNotReady ) ); |
|
196 |
|
197 TInt index = iMediaStreams.Find( &aMediaStream ); |
|
198 if ( index >= 0 ) |
|
199 { |
|
200 CMceMediaStream* stream = iMediaStreams[ index ]; |
|
201 iMediaStreams.Remove( index ); |
|
202 delete stream; |
|
203 } |
|
204 |
|
205 MCECLI_DEBUG("CMceSession::RemoveStreamL, Exit") |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CMceSession::InitializeL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CMceSession::InitializeL( |
|
213 TBool aClientSideMedia, |
|
214 TBool aDiscardUnusedCodecs ) |
|
215 { |
|
216 __ASSERT_ALWAYS( iManager, User::Leave( KErrArgument ) ); |
|
217 |
|
218 for( TInt i=0; i<iMediaStreams.Count();i++) |
|
219 { |
|
220 if ( aClientSideMedia ) |
|
221 { |
|
222 iMediaStreams[i]->InitializeL( iManager, *this ); |
|
223 } |
|
224 iMediaStreams[i]->InitializeL( *this, aDiscardUnusedCodecs ); |
|
225 } |
|
226 for( TInt i=0; i<iBundles.Count();i++) |
|
227 { |
|
228 iBundles[i]->InitializeL( *this ); |
|
229 } |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CMceSession::UpdateL |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 EXPORT_C void CMceSession::UpdateL( |
|
237 TUint32 aTimeout, |
|
238 CDesC8Array* aHeaders, |
|
239 HBufC8* aContentType, |
|
240 HBufC8* aContent, |
|
241 CDesC8Array* aContentHeaders ) |
|
242 { |
|
243 MCECLI_DEBUG("CMceSession::UpdateL, Entry") |
|
244 TState state = State(); |
|
245 MCECLI_DEBUG_CLISTATE( "state", state ) |
|
246 |
|
247 User::LeaveIfError( IsZombie() ? KErrArgument : KErrNone ); |
|
248 User::LeaveIfError( State() != EIdle ? KErrNone : KErrNotReady ); |
|
249 User::LeaveIfError( |
|
250 ( aContentType && aContent ) || |
|
251 !( aContentType || aContent || aContentHeaders ) ? |
|
252 KErrNone : KErrArgument ); |
|
253 |
|
254 // Leave if in incoming state givem too small timeout value |
|
255 User::LeaveIfError( !( aTimeout > 0 && State() == CMceSession::EIncoming ) || |
|
256 aTimeout <= SessionTimer() ? KErrNone : KErrArgument ); |
|
257 |
|
258 // initialize streams |
|
259 InitializeL( EFalse ); |
|
260 |
|
261 SetSIPParams( aHeaders, aContentType, aContentHeaders ); |
|
262 |
|
263 if( !( aTimeout == 0 && State() == CMceSession::EIncoming ) ) |
|
264 { |
|
265 FLAT_DATA( iTimeout ) = |
|
266 ( aTimeout < FLAT_DATA( iMinSE ) ? FLAT_DATA( iMinSE ) : aTimeout ); |
|
267 } |
|
268 |
|
269 SendUpdateL( aContent ); |
|
270 |
|
271 MCECLI_DEBUG("CMceSession::UpdateL, Exit") |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CMceSession::SendUpdateL |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void CMceSession::SendUpdateL( HBufC8* aContent ) |
|
279 { |
|
280 MCECLI_DEBUG("CMceSession::SendUpdateL, Entry") |
|
281 |
|
282 TCleanupItem sipParamsCleanup( SIPParamsCleanup, this ); |
|
283 CleanupStack::PushL( sipParamsCleanup ); |
|
284 |
|
285 TMceIds ids; |
|
286 PrepareForITC( ids ); |
|
287 ids.iState = State(); |
|
288 |
|
289 CMceMsgObject<CMceSession>* msg = |
|
290 new (ELeave) CMceMsgObject<CMceSession>( *this, EMceItcMsgTypeSession ); |
|
291 CleanupStack::PushL( msg ); |
|
292 |
|
293 // Don't pass aContent's ownership. Delete it when this function can't leave |
|
294 // anymore |
|
295 iSender->SendL( ids, EMceItcUpdate, *msg, aContent, EFalse ); |
|
296 |
|
297 CleanupStack::PopAndDestroy( msg ); |
|
298 |
|
299 FLAT_DATA( iState ) = static_cast<TState>( ids.iState ); |
|
300 TState state = State(); |
|
301 MCECLI_DEBUG_CLISTATE( "CMceSession::SendUpdateL, after ITC, state", state ) |
|
302 |
|
303 if ( ids.iStatus != KErrNone ) |
|
304 { |
|
305 MCECLI_DEBUG("CMceSession::SendUpdateL, update failed. rollback") |
|
306 |
|
307 TMceIds ids2; |
|
308 SynchronizeL( ids2 ); |
|
309 state = State(); |
|
310 MCECLI_DEBUG_CLISTATE( "CMceSession::SendUpdateL, after ITC, state", state ) |
|
311 |
|
312 CleanupStack::Pop(); // sipParamsCleanup |
|
313 SetSIPParams( NULL, NULL, NULL ); |
|
314 |
|
315 MMceSessionObserver* observer = iManager->SessionObserver(); |
|
316 TMceTransactionDataContainer* container = iManager->TransactionContainer(); |
|
317 if ( observer && container ) |
|
318 { |
|
319 container->SetStatusCode( ids2.iStatus ); |
|
320 observer->UpdateFailed( *this, container ); |
|
321 container->Clear(); |
|
322 } |
|
323 |
|
324 } |
|
325 else |
|
326 { |
|
327 CleanupStack::Pop(); // sipParamsCleanup |
|
328 SetSIPParams( NULL, NULL, NULL ); |
|
329 } |
|
330 |
|
331 delete aContent; |
|
332 |
|
333 MCECLI_DEBUG("CMceSession::SendUpdateL, Exit") |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CMceSession::SynchronizeL |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 void CMceSession::SynchronizeL( TMceIds& aIds ) |
|
341 { |
|
342 MCECLI_DEBUG("CMceSession::SynchronizeL, Entry") |
|
343 |
|
344 PrepareForITC( aIds ); |
|
345 aIds.iState = State(); |
|
346 |
|
347 HBufC8* encodedSrvSession = iSender->ReadStringL( aIds, EMceItcGetSession ); |
|
348 CleanupStack::PushL( encodedSrvSession ); |
|
349 |
|
350 CMceMsgObject<CMceSession>* srvSession = |
|
351 new (ELeave) CMceMsgObject<CMceSession>(); |
|
352 CleanupStack::PushL( srvSession ); |
|
353 srvSession->DecodeL( *encodedSrvSession ); |
|
354 |
|
355 srvSession->PushL(); |
|
356 UpdateL( *srvSession->iObject ); |
|
357 CleanupStack::PopAndDestroy( srvSession ); |
|
358 CleanupStack::PopAndDestroy( encodedSrvSession ); |
|
359 |
|
360 MCECLI_DEBUG("CMceSession::SynchronizeL, Exit") |
|
361 } |
|
362 |
|
363 // ----------------------------------------------------------------------------- |
|
364 // CMceSession::TerminateL |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 EXPORT_C void CMceSession::TerminateL( CDesC8Array* aHeaders, |
|
368 HBufC8* aContentType, |
|
369 HBufC8* aContent ) |
|
370 { |
|
371 MCECLI_DEBUG("CMceSession::TerminateL, Entry") |
|
372 TState state = State(); |
|
373 MCECLI_DEBUG_CLISTATE( "state", state ) |
|
374 |
|
375 User::LeaveIfError( IsZombie() ? KErrArgument : KErrNone ); |
|
376 User::LeaveIfError( State() != EIdle ? KErrNone : KErrNotReady ); |
|
377 User::LeaveIfError( |
|
378 ( aContentType && aContent ) || !( aContentType || aContent ) ? |
|
379 KErrNone : KErrArgument ); |
|
380 |
|
381 |
|
382 TMceIds ids; |
|
383 PrepareForITC( ids ); |
|
384 ids.iState = State(); |
|
385 |
|
386 CMceMsgSIPData* sipData = new (ELeave) CMceMsgSIPData( SipStrConsts::EBye, |
|
387 *aHeaders, *aContentType ); |
|
388 CleanupStack::PushL( sipData ); |
|
389 |
|
390 sipData->OwnershipRollbackPushLC(); |
|
391 |
|
392 iSender->SendL( ids, EMceItcTerminateSession, *sipData, aContent ); |
|
393 |
|
394 CleanupStack::Pop(); // sipData->OwnershipRollbackPushLC() |
|
395 |
|
396 sipData->Close(); |
|
397 CleanupStack::PopAndDestroy( sipData ); |
|
398 |
|
399 FLAT_DATA( iState ) = static_cast<TState>( ids.iState ); |
|
400 |
|
401 state = State(); |
|
402 MCECLI_DEBUG_CLISTATE( "CMceSession::TerminateL, after ITC, state", state ) |
|
403 MCECLI_DEBUG("CMceSession::TerminateL, Exit") |
|
404 } |
|
405 |
|
406 // ----------------------------------------------------------------------------- |
|
407 // CMceSession::Streams |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 EXPORT_C const RPointerArray<CMceMediaStream>& CMceSession::Streams() const |
|
411 { |
|
412 return iMediaStreams; |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CMceSession::Recipient |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 EXPORT_C const TDesC8& CMceSession::Recipient() const |
|
420 { |
|
421 return *FLAT_DATA( iRecipient ); |
|
422 } |
|
423 |
|
424 // ----------------------------------------------------------------------------- |
|
425 // CMceSession::Originator |
|
426 // ----------------------------------------------------------------------------- |
|
427 // |
|
428 EXPORT_C const TDesC8& CMceSession::Originator() const |
|
429 { |
|
430 return *FLAT_DATA( iOriginator ); |
|
431 } |
|
432 |
|
433 // ----------------------------------------------------------------------------- |
|
434 // CMceSession::Originator |
|
435 // ----------------------------------------------------------------------------- |
|
436 // |
|
437 EXPORT_C TUint32 CMceSession::SessionTimer() const |
|
438 { |
|
439 return FLAT_DATA( iTimeout ); |
|
440 } |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CMceSession::SetSessionSDPLinesL |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 EXPORT_C void CMceSession::SetSessionSDPLinesL( CDesC8Array* aSessionSDPLines ) |
|
447 { |
|
448 MCECLI_DEBUG("CMceSession::SetSessionSDPLinesL, Entry") |
|
449 |
|
450 User::LeaveIfError( State() == CMceSession::EIdle || |
|
451 State() == CMceSession::EIncoming || |
|
452 State() == CMceSession::EEstablished ? |
|
453 KErrNone : KErrNotReady ); |
|
454 CDesC8Array* lines = ( aSessionSDPLines ? aSessionSDPLines : |
|
455 new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ) ); |
|
456 delete FLAT_DATA( iLocalSessionSDPLines ); |
|
457 FLAT_DATA( iLocalSessionSDPLines ) = lines; |
|
458 MCECLI_DEBUG("CMceSession::SetSessionSDPLinesL, Exit") |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CMceSession::SessionSDPLinesL |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 EXPORT_C MDesC8Array* CMceSession::SessionSDPLinesL() |
|
466 { |
|
467 CDesC8Array* lines = new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ); |
|
468 CleanupStack::PushL( lines ); |
|
469 for ( TInt i=0; i < FLAT_DATA( iRemoteSessionSDPLines )->Count(); i++ ) |
|
470 { |
|
471 lines->AppendL( FLAT_DATA( iRemoteSessionSDPLines )->MdcaPoint( i ) ); |
|
472 } |
|
473 CleanupStack::Pop( lines ); |
|
474 return lines; |
|
475 } |
|
476 |
|
477 // ----------------------------------------------------------------------------- |
|
478 // CMceRefer::AssociatedEvents |
|
479 // ----------------------------------------------------------------------------- |
|
480 // |
|
481 EXPORT_C RPointerArray< CMceEvent >* CMceSession::AssociatedEventsL() const |
|
482 { |
|
483 return NULL; |
|
484 } |
|
485 |
|
486 // ----------------------------------------------------------------------------- |
|
487 // CMceRefer::AssociatedRefers |
|
488 // ----------------------------------------------------------------------------- |
|
489 // |
|
490 EXPORT_C RPointerArray< CMceRefer >* CMceSession::AssociatedRefersL() const |
|
491 { |
|
492 return NULL; |
|
493 } |
|
494 |
|
495 // ----------------------------------------------------------------------------- |
|
496 // CMceSession::GetModifierL |
|
497 // ----------------------------------------------------------------------------- |
|
498 // |
|
499 EXPORT_C void CMceSession::GetModifierL( TMceSessionModifier aModifier, |
|
500 TUint& aValue ) const |
|
501 { |
|
502 __ASSERT_ALWAYS( aModifier < KMceMaxSessionModifiers, |
|
503 User::Leave( KErrArgument ) ); |
|
504 TUint value = _FLAT_DATA->Modifier( aModifier ); |
|
505 aValue = value; |
|
506 } |
|
507 |
|
508 // ----------------------------------------------------------------------------- |
|
509 // CMceSession::SetModifierL |
|
510 // ----------------------------------------------------------------------------- |
|
511 // |
|
512 EXPORT_C void CMceSession::SetModifierL( TMceSessionModifier aModifier, |
|
513 TUint aValue ) |
|
514 { |
|
515 __ASSERT_ALWAYS( aModifier < KMceMaxSessionModifiers, |
|
516 User::Leave( KErrArgument ) ); |
|
517 _FLAT_DATA->Modifier( aModifier ) = aValue; |
|
518 if ( aModifier == KMceSecPreconditions && aValue == KMcePreconditionsE2ESupported ) |
|
519 { |
|
520 _FLAT_DATA->Modifier( KMcePreconditions ) = KMcePreconditionsNotUsed; |
|
521 } |
|
522 |
|
523 if ( aModifier == KMcePreconditions && aValue == KMcePreconditionsSupported && |
|
524 _FLAT_DATA->Modifier( KMceSecPreconditions ) != KMcePreconditionsE2ESupported ) |
|
525 { |
|
526 _FLAT_DATA->Modifier( KMceSecPreconditions ) = KMcePreconditionsNotUsed; |
|
527 } |
|
528 |
|
529 } |
|
530 |
|
531 |
|
532 // ----------------------------------------------------------------------------- |
|
533 // CMceSession::AddBundleL |
|
534 // ----------------------------------------------------------------------------- |
|
535 // |
|
536 EXPORT_C void CMceSession::AddBundleL( CMceStreamBundle* aBundle ) |
|
537 { |
|
538 |
|
539 aBundle->AddedL(); |
|
540 iBundles.AppendL( aBundle ); |
|
541 |
|
542 |
|
543 } |
|
544 |
|
545 // ----------------------------------------------------------------------------- |
|
546 // CMceSession::RemoveBundleL |
|
547 // ----------------------------------------------------------------------------- |
|
548 // |
|
549 EXPORT_C void CMceSession::RemoveBundleL( CMceStreamBundle& aBundle ) |
|
550 { |
|
551 TInt index = iBundles.Find( &aBundle ); |
|
552 User::LeaveIfError( index ); |
|
553 iBundles.Remove( index ); |
|
554 |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // CMceSession::Bundles |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 EXPORT_C const RPointerArray< CMceStreamBundle >& CMceSession::Bundles() const |
|
562 { |
|
563 return iBundles; |
|
564 } |
|
565 |
|
566 // ----------------------------------------------------------------------------- |
|
567 // CMceSession::Profile |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 EXPORT_C TUint32 CMceSession::Profile() const |
|
571 { |
|
572 return iProfileId; |
|
573 } |
|
574 |
|
575 |
|
576 // ----------------------------------------------------------------------------- |
|
577 // CMceSession::SetServiceTypeL |
|
578 // ----------------------------------------------------------------------------- |
|
579 // |
|
580 EXPORT_C void CMceSession::SetServiceTypeL( TUint32 aServiceType ) |
|
581 { |
|
582 MCECLI_DEBUG("CMceSession::SetServiceTypeL, Entry") |
|
583 |
|
584 User::LeaveIfError( State() == CMceSession::EIdle || |
|
585 State() == CMceSession::EIncoming ? |
|
586 KErrNone : KErrNotReady ); |
|
587 User::LeaveIfError ( aServiceType >= KMceMaxTypeOfServiceValue ? |
|
588 KErrArgument : KErrNone ); |
|
589 |
|
590 FLAT_DATA( iServiceType ) = aServiceType ; |
|
591 |
|
592 MCECLI_DEBUG("CMceSession::SetServiceTypeL, Exit") |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // CMceSession::ControlPathSecurityLevel() |
|
597 // ----------------------------------------------------------------------------- |
|
598 // |
|
599 EXPORT_C CMceSession::TControlPathSecurityLevel |
|
600 CMceSession::ControlPathSecurityLevel() const |
|
601 { |
|
602 if ( FLAT_DATA( iSipContactAddrSecure ) != CMceSession::EControlPathUnsecure && |
|
603 FLAT_DATA( iSipContactAddrSecure ) != CMceSession::EControlPathSecure ) |
|
604 { |
|
605 FLAT_DATA( iSipContactAddrSecure ) = CMceSession::EControlPathSecurityUnknown; |
|
606 } |
|
607 |
|
608 return FLAT_DATA( iSipContactAddrSecure ); |
|
609 } |
|
610 |
|
611 // ----------------------------------------------------------------------------- |
|
612 // CMceSession::ServiceType |
|
613 // ----------------------------------------------------------------------------- |
|
614 // |
|
615 EXPORT_C TUint32 CMceSession::ServiceType() const |
|
616 { |
|
617 return FLAT_DATA( iServiceType ); |
|
618 } |
|
619 |
|
620 // ----------------------------------------------------------------------------- |
|
621 // CMceSession::Type |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 TMceSessionType CMceSession::Type() const |
|
625 { |
|
626 return KMceSessionNormal; |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CMceSession::CMceSession |
|
631 // ----------------------------------------------------------------------------- |
|
632 // |
|
633 CMceSession::CMceSession( CMceManager* aManager, TUint32 aProfileId ) |
|
634 : iManager( aManager ), |
|
635 iProfileId( aProfileId ) |
|
636 { |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CMceSession::SerializationId |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 TUint64 CMceSession::SerializationId() const |
|
644 { |
|
645 return FLAT_DATA( SerializationId() ); |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CMceSession::InternalizeFlatL |
|
650 // ----------------------------------------------------------------------------- |
|
651 // |
|
652 void CMceSession::InternalizeFlatL( RReadStream& aReadStream ) |
|
653 { |
|
654 _FLAT_DATA->InternalizeFlatL( aReadStream ); |
|
655 } |
|
656 |
|
657 // ----------------------------------------------------------------------------- |
|
658 // CMceSession::ExternalizeFlatL |
|
659 // ----------------------------------------------------------------------------- |
|
660 // |
|
661 void CMceSession::ExternalizeFlatL( RWriteStream& aWriteStream ) |
|
662 { |
|
663 _FLAT_DATA->ExternalizeFlatL( aWriteStream ); |
|
664 } |
|
665 |
|
666 // ----------------------------------------------------------------------------- |
|
667 // CMceSession::InternalizeL |
|
668 // ----------------------------------------------------------------------------- |
|
669 // |
|
670 void CMceSession::InternalizeL( MMceComSerializationContext& aSerCtx ) |
|
671 { |
|
672 TMceSessionSerializer<CMceSession> serial( *this, _FLAT_DATA ); |
|
673 serial.InternalizeL( aSerCtx ); |
|
674 } |
|
675 |
|
676 // ----------------------------------------------------------------------------- |
|
677 // CMceSession::ExternalizeL |
|
678 // ----------------------------------------------------------------------------- |
|
679 // |
|
680 void CMceSession::ExternalizeL( MMceComSerializationContext& aSerCtx ) |
|
681 { |
|
682 TMceSessionSerializer<CMceSession> serial( *this, _FLAT_DATA ); |
|
683 serial.ExternalizeL( aSerCtx ); |
|
684 } |
|
685 |
|
686 |
|
687 // ----------------------------------------------------------------------------- |
|
688 // CMceSession::BaseFactory |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 TMceFactory CMceSession::BaseFactory() |
|
692 { |
|
693 return TMceFactory(); |
|
694 } |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // CMceSession::Factory |
|
698 // ----------------------------------------------------------------------------- |
|
699 // |
|
700 TMceFactory CMceSession::Factory() |
|
701 { |
|
702 return TMceFactory(); |
|
703 } |
|
704 |
|
705 |
|
706 // ----------------------------------------------------------------------------- |
|
707 // CMceSession::Id |
|
708 // ----------------------------------------------------------------------------- |
|
709 // |
|
710 TUint32 CMceSession::Id() const |
|
711 { |
|
712 return FLAT_DATA( iID ); |
|
713 } |
|
714 |
|
715 |
|
716 // ----------------------------------------------------------------------------- |
|
717 // CMceSession::DialogId |
|
718 // ----------------------------------------------------------------------------- |
|
719 // |
|
720 TUint32 CMceSession::DialogId() const |
|
721 { |
|
722 return FLAT_DATA( iDialogId ); |
|
723 } |
|
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // CMceSession::ITCSender |
|
727 // ----------------------------------------------------------------------------- |
|
728 // |
|
729 CMceItcSender& CMceSession::ITCSender() const |
|
730 { |
|
731 return *iSender; |
|
732 } |
|
733 |
|
734 // ----------------------------------------------------------------------------- |
|
735 // CMceSession::Manager |
|
736 // ----------------------------------------------------------------------------- |
|
737 // |
|
738 CMceManager& CMceSession::Manager() const |
|
739 { |
|
740 return *iManager; |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CMceSession::SetFCObserver |
|
745 // ----------------------------------------------------------------------------- |
|
746 // |
|
747 void CMceSession::SetFCObserver( MMceFcMsgObserver* aPtr) |
|
748 { |
|
749 iFCObserver = aPtr; |
|
750 } |
|
751 |
|
752 // ----------------------------------------------------------------------------- |
|
753 // CMceSession::ConstructL |
|
754 // ----------------------------------------------------------------------------- |
|
755 // |
|
756 void CMceSession::ConstructL( TBool aUpdateSession ) |
|
757 { |
|
758 MCECLI_DEBUG("CMceSession::ConstructL, Entry") |
|
759 |
|
760 User::LeaveIfNull( iFlatData ); |
|
761 |
|
762 if ( iManager && !aUpdateSession ) |
|
763 { |
|
764 TBuf8<64> iapId; |
|
765 iapId.AppendNum( FLAT_DATA( iIapId ) ); |
|
766 |
|
767 CDesC8ArrayFlat* params = |
|
768 new (ELeave) CDesC8ArrayFlat( KMceArrayGranularity ); |
|
769 CleanupStack::PushL( params ); |
|
770 params->AppendL( Originator() ); |
|
771 params->AppendL( Recipient() ); |
|
772 params->AppendL( iapId ); |
|
773 |
|
774 FLAT_DATA( iID ) = iManager->RegisterSessionL( this, |
|
775 *params, |
|
776 FLAT_DATA( iDialogId ), |
|
777 FLAT_DATA( iIsConnectionActive ) ); |
|
778 |
|
779 CleanupStack::PopAndDestroy( params ); |
|
780 |
|
781 //get server |
|
782 RMce& server = iManager->ServerSession(); |
|
783 |
|
784 //create sender |
|
785 iSender = CMceItcSender::NewL( server ); |
|
786 //create receiver |
|
787 iReceiver = new (ELeave) CMceSessionReceiver( server, *this ); |
|
788 } |
|
789 |
|
790 MCECLI_DEBUG("CMceSession::ConstructL, Exit") |
|
791 } |
|
792 |
|
793 // ----------------------------------------------------------------------------- |
|
794 // CMceSession::PrepareForITC |
|
795 // ----------------------------------------------------------------------------- |
|
796 // |
|
797 void CMceSession::PrepareForITC( TMceIds& aId ) |
|
798 { |
|
799 |
|
800 aId.iAppUID = Manager().AppUid().iUid; |
|
801 aId.iSessionID = Id(); |
|
802 aId.iManagerType = KMceCSSIPSession; |
|
803 aId.iProfileID = iProfileId; |
|
804 |
|
805 } |
|
806 |
|
807 |
|
808 // ----------------------------------------------------------------------------- |
|
809 // CMceSession::EventReceivedL |
|
810 // ----------------------------------------------------------------------------- |
|
811 // |
|
812 void CMceSession::EventReceivedL( TMceIds& aId ) |
|
813 { |
|
814 TMceEvent event( aId, NULL, NULL ); |
|
815 EventReceivedL( event ); |
|
816 } |
|
817 |
|
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // CMceSession::EventReceivedL |
|
821 // ----------------------------------------------------------------------------- |
|
822 // |
|
823 void CMceSession::EventReceivedL( TMceIds& aId, CMceMsgBase& aMessage ) |
|
824 { |
|
825 TMceEvent event( aId, &aMessage, NULL ); |
|
826 EventReceivedL( event ); |
|
827 } |
|
828 |
|
829 |
|
830 // ----------------------------------------------------------------------------- |
|
831 // CMceSession::IsZombie |
|
832 // ----------------------------------------------------------------------------- |
|
833 // |
|
834 TBool CMceSession::IsZombie() |
|
835 { |
|
836 return !iReceiver && !iSender; |
|
837 } |
|
838 |
|
839 // ----------------------------------------------------------------------------- |
|
840 // CMceSession::IncomingUpdateL |
|
841 // ----------------------------------------------------------------------------- |
|
842 // |
|
843 void CMceSession::IncomingUpdateL( CMceInSession* aInSession, HBufC8* aContent ) |
|
844 { |
|
845 MCECLI_DEBUG("CMceSession::IncomingUpdateL, Entry") |
|
846 TState state = State(); |
|
847 MCECLI_DEBUG_CLISTATE("state", state ) |
|
848 state = aInSession->State(); |
|
849 MCECLI_DEBUG_CLISTATE("update state", state ) |
|
850 |
|
851 MMceInSessionObserver* observer = iManager->InSessionObserver(); |
|
852 if ( !observer ) |
|
853 { |
|
854 MCECLI_DEBUG("CMceSession::IncomingUpdateL, no observer. reject") |
|
855 SendITCEventL( EMceItcRejectSession ); |
|
856 delete aInSession; |
|
857 return; |
|
858 } |
|
859 |
|
860 CDesC8Array* headers = NULL; |
|
861 HBufC8* contentType = NULL; |
|
862 CDesC8Array* contentHeaders = NULL; |
|
863 aInSession->GetSIPParams( headers, contentType, contentHeaders ); |
|
864 |
|
865 TInt pushs = 0; |
|
866 |
|
867 if ( headers ) |
|
868 { |
|
869 CleanupStack::PushL( headers );++pushs; |
|
870 } |
|
871 |
|
872 if ( contentType ) |
|
873 { |
|
874 CleanupStack::PushL( contentType );++pushs; |
|
875 } |
|
876 |
|
877 if ( contentHeaders ) |
|
878 { |
|
879 CleanupStack::PushL( contentHeaders );++pushs; |
|
880 } |
|
881 |
|
882 TMceTransactionDataContainer* container = iManager->TransactionContainer(); |
|
883 |
|
884 if ( container ) |
|
885 { |
|
886 container->SetHeaders( headers ); |
|
887 container->SetContentType( contentType ); |
|
888 container->SetContent( aContent ); |
|
889 container->SetContentHeaders( contentHeaders ); |
|
890 CleanupStack::Pop( pushs ); |
|
891 } |
|
892 else |
|
893 { |
|
894 CleanupStack::PopAndDestroy( pushs ); |
|
895 } |
|
896 |
|
897 iManager->IncomingSessionUpdateL( *aInSession, *this ); |
|
898 |
|
899 MCECLI_DEBUG("CMceSession::IncomingUpdateL, this session is now zombie.") |
|
900 |
|
901 observer->IncomingUpdate( *this, aInSession, container ); |
|
902 |
|
903 if ( container ) |
|
904 { |
|
905 container->Clear(); |
|
906 } |
|
907 |
|
908 |
|
909 MCECLI_DEBUG("CMceSession::IncomingUpdateL, Exit") |
|
910 |
|
911 } |
|
912 |
|
913 |
|
914 // ----------------------------------------------------------------------------- |
|
915 // CMceSession::SetZombie |
|
916 // ----------------------------------------------------------------------------- |
|
917 // |
|
918 void CMceSession::SetZombie( CMceInSession& aInSession ) |
|
919 { |
|
920 aInSession.iManager = iManager; |
|
921 iManager = NULL; |
|
922 |
|
923 aInSession.iProfileId = iProfileId; |
|
924 |
|
925 aInSession.iSender = iSender; |
|
926 iSender = NULL; |
|
927 |
|
928 aInSession.iReceiver = iReceiver; |
|
929 iReceiver->ReplaceSession( aInSession ); |
|
930 iReceiver = NULL; |
|
931 |
|
932 aInSession.iFCObserver = iFCObserver; |
|
933 iFCObserver = NULL; |
|
934 |
|
935 } |
|
936 |
|
937 |
|
938 // ----------------------------------------------------------------------------- |
|
939 // CMceSession::EventReceivedL |
|
940 // ----------------------------------------------------------------------------- |
|
941 // |
|
942 void CMceSession::EventReceivedL( TMceIds& aId, |
|
943 CMceMsgBase& aMessage, |
|
944 HBufC8* aContent ) |
|
945 { |
|
946 TMceEvent event( aId, &aMessage, aContent ); |
|
947 EventReceivedL( event ); |
|
948 } |
|
949 |
|
950 // ----------------------------------------------------------------------------- |
|
951 // CMceSession::ErrorOccuredL |
|
952 // ----------------------------------------------------------------------------- |
|
953 // |
|
954 void CMceSession::ErrorOccuredL( TInt aError ) |
|
955 { |
|
956 MCECLI_DEBUG("CMceSession::ErrorOccuredL, Entry") |
|
957 MCECLI_DEBUG_DVALUE("error", aError ) |
|
958 |
|
959 User::LeaveIfError( iManager->SessionObserver() ? KErrNone : KErrArgument ); |
|
960 FLAT_DATA( iState ) = CMceSession::ETerminated; |
|
961 |
|
962 |
|
963 iManager->SessionObserver()->Failed( *this, aError ); |
|
964 |
|
965 TState state = State(); |
|
966 MCECLI_DEBUG_CLISTATE( "CMceSession::ErrorOccuredL, before exit. state", state ) |
|
967 MCECLI_DEBUG("CMceSession::ErrorOccuredL, Exit") |
|
968 } |
|
969 |
|
970 // ----------------------------------------------------------------------------- |
|
971 // CMceSession::FCMessageReceived |
|
972 // ----------------------------------------------------------------------------- |
|
973 // |
|
974 void CMceSession::FCMessageReceived( HBufC8* aMessage ) |
|
975 { |
|
976 MCECLI_DEBUG("CMceSession::FCMessageReceived, Entry") |
|
977 |
|
978 if ( iFCObserver ) |
|
979 { |
|
980 iFCObserver->FCMsgReceived( *this, aMessage ); |
|
981 } |
|
982 else |
|
983 { |
|
984 delete aMessage; |
|
985 } |
|
986 MCECLI_DEBUG("CMceSession::FCMessageReceived, Exit") |
|
987 } |
|
988 |
|
989 // ----------------------------------------------------------------------------- |
|
990 // CMceSession::FCErrorOccurred |
|
991 // ----------------------------------------------------------------------------- |
|
992 // |
|
993 void CMceSession::FCErrorOccurred( TInt aError ) |
|
994 { |
|
995 MCECLI_DEBUG("CMceSession::FCErrorOccurred, Entry") |
|
996 MCECLI_DEBUG_DVALUE("error", aError ) |
|
997 |
|
998 if ( iFCObserver ) |
|
999 { |
|
1000 iFCObserver->FCMsgErrorOccurred( *this, aError ); |
|
1001 } |
|
1002 |
|
1003 MCECLI_DEBUG("CMceSession::FCErrorOccurred, Exit") |
|
1004 } |
|
1005 |
|
1006 // ----------------------------------------------------------------------------- |
|
1007 // CMceSession::EventReceivedL |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // |
|
1010 void CMceSession::EventReceivedL( TMceEvent& aEvent ) |
|
1011 { |
|
1012 MCECLI_DEBUG( "CMceSession::EventReceivedL, Entry" ) |
|
1013 TState state = State(); |
|
1014 MCECLI_DEBUG_CLISTATE( "this: state", state ) |
|
1015 MCECLI_DEBUG_DVALUE( "this: id", Id() ) |
|
1016 |
|
1017 User::LeaveIfError( |
|
1018 aEvent.Id().iSessionID == Id() ? KErrNone : KErrGeneral ); |
|
1019 |
|
1020 if ( aEvent.Id().IsSessionId() ) |
|
1021 { |
|
1022 MCECLI_DEBUG("CMceSession::EventReceivedL, for session") |
|
1023 HandleEvent( aEvent ); |
|
1024 } |
|
1025 else |
|
1026 { |
|
1027 MCECLI_DEBUG( "CMceSession::EventReceivedL, for media" ) |
|
1028 TInt j = 0; |
|
1029 TInt status = KMceEventNotConsumed; |
|
1030 while ( status != KMceEventConsumed && j < iMediaStreams.Count() ) |
|
1031 { |
|
1032 CMceMediaStream* stream = iMediaStreams[j]; |
|
1033 status = stream->EventReceivedL( aEvent ); |
|
1034 if ( status == KMceEventUpdate ) |
|
1035 { |
|
1036 MCECLI_DEBUG( "CMceSession::EventReceivedL, \ |
|
1037 update media stream by replacing old version with new one" ) |
|
1038 CMceMsgObject<CMceMediaStream>* updateMsg = |
|
1039 static_cast<CMceMsgObject<CMceMediaStream>*>( aEvent.Message() ); |
|
1040 CMceMediaStream* updateStream = updateMsg->Object(); |
|
1041 CleanupStack::PushL( updateStream ); |
|
1042 iMediaStreams.Remove( j ); |
|
1043 delete stream; |
|
1044 updateStream->InitializeL( *this, EFalse ); |
|
1045 AddStreamL( updateStream ); |
|
1046 CleanupStack::Pop( updateStream ); |
|
1047 updateStream->Updated(); |
|
1048 status = KMceEventConsumed; |
|
1049 } |
|
1050 j++; |
|
1051 } |
|
1052 |
|
1053 } |
|
1054 MCECLI_DEBUG( "CMceSession::EventReceivedL, Exit" ) |
|
1055 } |
|
1056 |
|
1057 // ----------------------------------------------------------------------------- |
|
1058 // CMceSession::Updated |
|
1059 // ----------------------------------------------------------------------------- |
|
1060 // |
|
1061 void CMceSession::Updated() |
|
1062 { |
|
1063 MMceSessionObserver* observer = iManager->SessionObserver(); |
|
1064 TMceTransactionDataContainer* container = iManager->TransactionContainer(); |
|
1065 |
|
1066 if ( observer ) |
|
1067 { |
|
1068 observer->SessionStateChanged( *this , container); |
|
1069 } |
|
1070 |
|
1071 } |
|
1072 |
|
1073 |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // CMceSession::SetContainer |
|
1076 // ----------------------------------------------------------------------------- |
|
1077 // |
|
1078 TBool CMceSession::SetContainer( CMceMsgSIPReply& aReply, HBufC8* aContent ) |
|
1079 { |
|
1080 if ( !&aReply ) |
|
1081 { |
|
1082 delete aContent; |
|
1083 return ETrue; |
|
1084 } |
|
1085 TBool contentDeleted( EFalse ); |
|
1086 TMceTransactionDataContainer* container = iManager->TransactionContainer(); |
|
1087 |
|
1088 if ( container ) |
|
1089 { |
|
1090 container->SetStatusCode( aReply.iCode ); |
|
1091 container->SetReasonPhrase( aReply.Reason() ); |
|
1092 container->SetHeaders( aReply.Headers() ); |
|
1093 container->SetContentType( aReply.ContentType() ); |
|
1094 container->SetContent( aContent ); |
|
1095 } |
|
1096 else |
|
1097 { |
|
1098 aReply.Close(); |
|
1099 delete aContent; |
|
1100 contentDeleted = ETrue; |
|
1101 } |
|
1102 return contentDeleted; |
|
1103 } |
|
1104 |
|
1105 |
|
1106 // ----------------------------------------------------------------------------- |
|
1107 // CMceSession::SetContainer |
|
1108 // ----------------------------------------------------------------------------- |
|
1109 // |
|
1110 TBool CMceSession::SetContainer( CMceMsgSIPData& aRequest, HBufC8* aContent ) |
|
1111 { |
|
1112 if ( !&aRequest ) |
|
1113 { |
|
1114 delete aContent; |
|
1115 return ETrue; |
|
1116 } |
|
1117 TBool contentDeleted( EFalse ); |
|
1118 TMceTransactionDataContainer* container = iManager->TransactionContainer(); |
|
1119 |
|
1120 if ( container ) |
|
1121 { |
|
1122 container->SetHeaders( aRequest.Headers() ); |
|
1123 container->SetContentType( aRequest.ContentType() ); |
|
1124 container->SetContent( aContent ); |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 aRequest.Close(); |
|
1129 delete aContent; |
|
1130 contentDeleted = ETrue; |
|
1131 } |
|
1132 return contentDeleted; |
|
1133 } |
|
1134 |
|
1135 |
|
1136 // ----------------------------------------------------------------------------- |
|
1137 // CMceSession::SetContainer |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // |
|
1140 void CMceSession::SetContainer( CMceMsgArray<TMceFactory>& aMsgArray, |
|
1141 HBufC8* aContent ) |
|
1142 { |
|
1143 |
|
1144 if ( !&aMsgArray ) |
|
1145 { |
|
1146 delete aContent; |
|
1147 return; |
|
1148 } |
|
1149 |
|
1150 |
|
1151 for( TInt i = 0; i < aMsgArray.iArray.Count(); i++ ) |
|
1152 { |
|
1153 CMceMsgBase* msg = aMsgArray.iArray[ i ]; |
|
1154 |
|
1155 if ( msg->Type() == EMceItcMsgTypeSIPReply ) |
|
1156 { |
|
1157 if ( SetContainer( static_cast<CMceMsgSIPReply&>( *msg ), aContent ) ) |
|
1158 { |
|
1159 // Content was deleted |
|
1160 aContent = NULL; |
|
1161 } |
|
1162 } |
|
1163 else if ( msg->Type() == EMceItcMsgTypeSIPData ) |
|
1164 { |
|
1165 if ( SetContainer( static_cast<CMceMsgSIPData&>( *msg ), aContent ) ) |
|
1166 { |
|
1167 // Content was deleted |
|
1168 aContent = NULL; |
|
1169 } |
|
1170 } |
|
1171 else if ( msg->Type() == EMceItcMsgTypeSession ) |
|
1172 { |
|
1173 CMceSession* session = |
|
1174 static_cast<CMceMsgObject<CMceSession>*>( msg )->Object(); |
|
1175 TRAPD( error, UpdateL( *session ) ); |
|
1176 if ( error != KErrNone ) |
|
1177 { |
|
1178 //TBD |
|
1179 } |
|
1180 delete session; |
|
1181 } |
|
1182 else |
|
1183 { |
|
1184 } |
|
1185 } |
|
1186 } |
|
1187 |
|
1188 // ----------------------------------------------------------------------------- |
|
1189 // CMceSession::HandleEvent |
|
1190 // ----------------------------------------------------------------------------- |
|
1191 // |
|
1192 void CMceSession::HandleEvent( TMceEvent& aEvent ) |
|
1193 { |
|
1194 MCECLI_DEBUG("CMceSession::HandleEvent, Entry") |
|
1195 |
|
1196 if ( aEvent.Action() == EMceItcSessionConnectionStateChanged ) |
|
1197 { |
|
1198 MCECLI_DEBUG("CMceSession::HandleEvent, connection state changed") |
|
1199 FLAT_DATA( iIsConnectionActive ) = |
|
1200 static_cast<TBool>( aEvent.ActionData() ); |
|
1201 iManager->SessionObserver()->SessionConnectionStateChanged( |
|
1202 *this, |
|
1203 FLAT_DATA( iIsConnectionActive ) ); |
|
1204 return; |
|
1205 } |
|
1206 |
|
1207 if ( aEvent.Action() == EMceItcStateChanged || |
|
1208 aEvent.Action() == EMceItcUpdateFailed ) |
|
1209 { |
|
1210 TMceTransactionDataContainer* container = iManager->TransactionContainer(); |
|
1211 MMceSessionObserver* observer = iManager->SessionObserver(); |
|
1212 HBufC8* content = aEvent.Content(); |
|
1213 |
|
1214 FLAT_DATA( iState ) = |
|
1215 static_cast<CMceSession::TState>( aEvent.ActionData() ); |
|
1216 |
|
1217 MCECLI_DEBUG("CMceSession::HandleEvent, session state changed" ) |
|
1218 |
|
1219 if ( aEvent.MessageType() == EMceItcMsgTypeSIPReply ) |
|
1220 { |
|
1221 MCECLI_DEBUG("CMceSession::HandleEvent, caused by sip reply") |
|
1222 CMceMsgSIPReply* reply = |
|
1223 static_cast<CMceMsgSIPReply*>( aEvent.Message() ); |
|
1224 if ( observer ) |
|
1225 { |
|
1226 SetContainer( *reply, content ); |
|
1227 if ( aEvent.Action() == EMceItcStateChanged ) |
|
1228 { |
|
1229 observer->SessionStateChanged( *this, container ); |
|
1230 } |
|
1231 else |
|
1232 { |
|
1233 MCECLI_DEBUG("CMceSession::HandleEvent, update failed") |
|
1234 observer->UpdateFailed( *this, container ); |
|
1235 } |
|
1236 |
|
1237 if ( container ) |
|
1238 { |
|
1239 container->Clear(); |
|
1240 } |
|
1241 } |
|
1242 else |
|
1243 { |
|
1244 if ( reply ) |
|
1245 { |
|
1246 reply->Close(); |
|
1247 } |
|
1248 delete content; |
|
1249 } |
|
1250 } |
|
1251 else if ( aEvent.MessageType() == EMceItcMsgTypeSIPData ) |
|
1252 { |
|
1253 MCECLI_DEBUG("CMceSession::HandleEvent, caused by sip request") |
|
1254 CMceMsgSIPData* request = |
|
1255 static_cast<CMceMsgSIPData*>( aEvent.Message() ); |
|
1256 if ( observer ) |
|
1257 { |
|
1258 SetContainer( *request, content ); |
|
1259 if ( aEvent.Action() == EMceItcStateChanged ) |
|
1260 { |
|
1261 observer->SessionStateChanged( *this, container ); |
|
1262 } |
|
1263 else |
|
1264 { |
|
1265 MCECLI_DEBUG("CMceSession::HandleEvent, update failed") |
|
1266 observer->UpdateFailed( *this, container ); |
|
1267 } |
|
1268 |
|
1269 if ( container ) |
|
1270 { |
|
1271 container->Clear(); |
|
1272 } |
|
1273 } |
|
1274 else |
|
1275 { |
|
1276 if ( request ) |
|
1277 { |
|
1278 request->Close(); |
|
1279 } |
|
1280 delete content; |
|
1281 } |
|
1282 } |
|
1283 else if ( aEvent.MessageType() == EMceItcMsgTypeMessageArray ) |
|
1284 { |
|
1285 MCECLI_DEBUG("CMceSession::HandleEvent, caused by sip request/reply") |
|
1286 |
|
1287 CMceMsgArray<TMceFactory>* msgArray = |
|
1288 static_cast<CMceMsgArray<TMceFactory>*>( aEvent.Message() ); |
|
1289 if ( observer ) |
|
1290 { |
|
1291 if ( aEvent.Action() == EMceItcStateChanged ) |
|
1292 { |
|
1293 SetContainer( *msgArray, content ); |
|
1294 observer->SessionStateChanged( *this, container ); |
|
1295 } |
|
1296 else |
|
1297 { |
|
1298 if ( aEvent.Id().iStatus != KMceErrOldSchool ) |
|
1299 { |
|
1300 SetContainer( *msgArray, content ); |
|
1301 } |
|
1302 UpdateFailed( aEvent, container ); |
|
1303 } |
|
1304 |
|
1305 if ( container ) |
|
1306 { |
|
1307 container->Clear(); |
|
1308 } |
|
1309 } |
|
1310 else |
|
1311 { |
|
1312 if ( msgArray ) |
|
1313 { |
|
1314 msgArray->Close(); |
|
1315 } |
|
1316 delete content; |
|
1317 } |
|
1318 } |
|
1319 else |
|
1320 { |
|
1321 if ( aEvent.MessageType() == EMceItcMsgTypeSession ) |
|
1322 { |
|
1323 MCECLI_DEBUG("CMceSession::HandleEvent, caused by session update") |
|
1324 |
|
1325 CMceMsgObject<CMceSession>* updateMsg = |
|
1326 static_cast<CMceMsgObject<CMceSession>*>( aEvent.Message() ); |
|
1327 CMceSession* session = updateMsg->Object(); |
|
1328 TRAPD( error, UpdateL( *session ) ); |
|
1329 if ( error != KErrNone ) |
|
1330 { |
|
1331 //TBD |
|
1332 } |
|
1333 delete session; |
|
1334 } |
|
1335 if ( aEvent.Action() == EMceItcUpdateFailed && observer ) |
|
1336 { |
|
1337 observer->UpdateFailed( *this, container ); |
|
1338 } |
|
1339 else |
|
1340 { |
|
1341 Updated(); |
|
1342 } |
|
1343 } |
|
1344 MCECLI_DEBUG("CMceSession::HandleEvent, Exit") |
|
1345 return; |
|
1346 } |
|
1347 |
|
1348 // Handling of Request / Responses Received within a Session |
|
1349 |
|
1350 if ( aEvent.Action() == EMceItcRequestReceived ) |
|
1351 |
|
1352 { |
|
1353 TRAPD( error, HandleEventRequestReceivedL (aEvent)); |
|
1354 if ( error != KErrNone ) |
|
1355 { |
|
1356 //TBD |
|
1357 } |
|
1358 } |
|
1359 |
|
1360 if ( aEvent.Action() == EMceItcResponseReceived ) |
|
1361 { |
|
1362 TRAPD( error, HandleEventResponseReceivedL (aEvent)); |
|
1363 if ( error != KErrNone ) |
|
1364 { |
|
1365 //TBD |
|
1366 } |
|
1367 |
|
1368 } |
|
1369 |
|
1370 MCECLI_DEBUG("CMceSession::HandleEvent, Exit") |
|
1371 return; |
|
1372 } |
|
1373 |
|
1374 // ----------------------------------------------------------------------------- |
|
1375 // CMceSession::HandleEventRequestReceivedL |
|
1376 // ----------------------------------------------------------------------------- |
|
1377 // |
|
1378 void CMceSession::HandleEventRequestReceivedL( TMceEvent& aEvent ) |
|
1379 { |
|
1380 MCECLI_DEBUG("CMceSession::HandleEventRequestReceivedL, Entry ") |
|
1381 |
|
1382 TMceTransactionDataContainer* container = iManager->TransactionContainer(); |
|
1383 HBufC8* content = aEvent.Content(); |
|
1384 |
|
1385 MMceInTransactionObserver* observer = iManager->InTransactionObserver(); |
|
1386 |
|
1387 if ( aEvent.MessageType() == EMceItcMsgTypeSIPRequest ) |
|
1388 { |
|
1389 |
|
1390 if ( observer ) |
|
1391 { |
|
1392 if ( aEvent.Action() == EMceItcRequestReceived ) |
|
1393 { |
|
1394 TMceTransactionId TransactonID; |
|
1395 TransactonID = aEvent.Id().iTransactionID; |
|
1396 |
|
1397 CMceMsgSIPRequest* msgRequest = |
|
1398 static_cast<CMceMsgSIPRequest*>( aEvent.Message() ); |
|
1399 |
|
1400 SetContainer( *msgRequest, content ); |
|
1401 |
|
1402 observer->IncomingRequest( *msgRequest->RequestMethod(), |
|
1403 *this, TransactonID, container ); |
|
1404 } |
|
1405 |
|
1406 if ( container ) |
|
1407 { |
|
1408 container->Clear(); |
|
1409 } |
|
1410 } |
|
1411 |
|
1412 else |
|
1413 { |
|
1414 // Reject the Transaction with 501 Error Response |
|
1415 // Saying Its not implemented. |
|
1416 const TUint KMceSipNotImplemented = 501; |
|
1417 _LIT8( KNotImplemented ,"Not Implemented"); |
|
1418 |
|
1419 HBufC8* reason = KNotImplemented().AllocLC(); |
|
1420 SendResponseL( aEvent.Id().iTransactionID, |
|
1421 *reason, |
|
1422 KMceSipNotImplemented, |
|
1423 NULL, |
|
1424 NULL, |
|
1425 NULL); |
|
1426 |
|
1427 CleanupStack::PopAndDestroy( reason ); |
|
1428 |
|
1429 delete content; |
|
1430 } |
|
1431 } |
|
1432 |
|
1433 MCECLI_DEBUG("CMceSession::HandleEventRequestReceivedL, Exit ") |
|
1434 } |
|
1435 |
|
1436 // ----------------------------------------------------------------------------- |
|
1437 // CMceSession::HandleEventResponseReceivedL |
|
1438 // ----------------------------------------------------------------------------- |
|
1439 // |
|
1440 void CMceSession::HandleEventResponseReceivedL( TMceEvent& aEvent ) |
|
1441 { |
|
1442 MCECLI_DEBUG("CMceSession::HandleEventResponseReceivedL, Entry" ) |
|
1443 TMceTransactionDataContainer* container = iManager->TransactionContainer(); |
|
1444 HBufC8* content = aEvent.Content(); |
|
1445 |
|
1446 if ( aEvent.MessageType() == EMceItcMsgTypeSIPReply ) |
|
1447 { |
|
1448 MMceTransactionObserver* observer = iManager->TransactionObserver(); |
|
1449 |
|
1450 CMceMsgSIPReply* msgReply = |
|
1451 static_cast<CMceMsgSIPReply*>( aEvent.Message() ); |
|
1452 |
|
1453 if ( observer ) |
|
1454 { |
|
1455 SetContainer( *msgReply, content ); |
|
1456 TMceTransactionId TransactonID; |
|
1457 TransactonID = aEvent.Id().iTransactionID; |
|
1458 observer->TransactionResponse(*this, TransactonID, container ); |
|
1459 |
|
1460 if ( container ) |
|
1461 { |
|
1462 container->Clear(); |
|
1463 } |
|
1464 } |
|
1465 else |
|
1466 { |
|
1467 if ( msgReply ) |
|
1468 { |
|
1469 msgReply->Close(); |
|
1470 } |
|
1471 delete content; |
|
1472 } |
|
1473 } |
|
1474 |
|
1475 MCECLI_DEBUG("CMceSession::HandleEventResponseReceivedL, Exit" ) |
|
1476 } |
|
1477 |
|
1478 // ----------------------------------------------------------------------------- |
|
1479 // CMceSession::UpdateFailed |
|
1480 // ----------------------------------------------------------------------------- |
|
1481 // |
|
1482 void CMceSession::UpdateFailed( TMceEvent& aEvent, |
|
1483 TMceTransactionDataContainer* aContainer ) |
|
1484 { |
|
1485 MMceSessionObserver* observer = iManager->SessionObserver(); |
|
1486 HBufC8* content = aEvent.Content(); |
|
1487 |
|
1488 if ( aEvent.Id().iStatus == KMceErrOldSchool ) |
|
1489 { |
|
1490 TRAPD( leaveErr, SendUpdateL( content ) ); |
|
1491 if ( leaveErr == KMceErrOldSchool ) |
|
1492 { |
|
1493 observer->UpdateFailed( *this, aContainer ); |
|
1494 } |
|
1495 } |
|
1496 else |
|
1497 { |
|
1498 observer->UpdateFailed( *this, aContainer ); |
|
1499 } |
|
1500 } |
|
1501 |
|
1502 // ----------------------------------------------------------------------------- |
|
1503 // CMceSession::UpdateL |
|
1504 // ----------------------------------------------------------------------------- |
|
1505 // |
|
1506 void CMceSession::UpdateL( CMceSession& aSession ) |
|
1507 { |
|
1508 MCECLI_DEBUG("CMceSession::UpdateL(received), Entry") |
|
1509 MCECLI_DEBUG("CMceSession::UpdateL(received), updating session data") |
|
1510 |
|
1511 iFlatData->UpdateFlatL( *aSession.iFlatData ); |
|
1512 |
|
1513 MCECLI_DEBUG("CMceSession::UpdateL(received), \ |
|
1514 removing old streams and bundles") |
|
1515 iMediaStreams.ResetAndDestroy(); |
|
1516 iBundles.ResetAndDestroy(); |
|
1517 |
|
1518 while( aSession.iMediaStreams.Count() > 0 ) |
|
1519 { |
|
1520 CMceMediaStream* stream = aSession.iMediaStreams[0]; |
|
1521 aSession.iMediaStreams.Remove( 0 ); |
|
1522 CleanupStack::PushL( stream ); |
|
1523 CMceSession::AddStreamL( stream ); |
|
1524 CleanupStack::Pop( stream ); |
|
1525 MCECLI_DEBUG("CMceSession::UpdateL(received), added updated stream") |
|
1526 MCECLI_DEBUG_DVALUE("id", stream->Id().iId ) |
|
1527 MCECLI_DEBUG_DVALUE("enabled", stream->IsEnabled() ) |
|
1528 CMceMediaStream::TState state = stream->State(); |
|
1529 MCECLI_DEBUG_MEDIASTATE("state", state ) |
|
1530 } |
|
1531 |
|
1532 while( aSession.iBundles.Count() > 0 ) |
|
1533 { |
|
1534 CMceStreamBundle* bundle = aSession.iBundles[0]; |
|
1535 aSession.iBundles.Remove( 0 ); |
|
1536 CleanupStack::PushL( bundle ); |
|
1537 AddBundleL( bundle ); |
|
1538 CleanupStack::Pop( bundle ); |
|
1539 MCECLI_DEBUG("CMceSession::UpdateL(received), added updated bundle") |
|
1540 } |
|
1541 |
|
1542 InitializeL(); |
|
1543 |
|
1544 MCECLI_DEBUG("CMceSession::UpdateL(received), Exit") |
|
1545 } |
|
1546 |
|
1547 // ----------------------------------------------------------------------------- |
|
1548 // CMceSession::SendITCEventL |
|
1549 // ----------------------------------------------------------------------------- |
|
1550 // |
|
1551 void CMceSession::SendITCEventL( TUint8 aITCFunction ) |
|
1552 { |
|
1553 __ASSERT_ALWAYS( iSender, User::Leave( KErrGeneral ) ); |
|
1554 |
|
1555 TMceIds ids; |
|
1556 PrepareForITC( ids ); |
|
1557 ids.iState = State(); |
|
1558 iSender->SendL( ids, static_cast<TMceItcFunctions>( aITCFunction ) ); |
|
1559 //update the state |
|
1560 FLAT_DATA( iState ) = static_cast<TState>( ids.iState ); |
|
1561 } |
|
1562 |
|
1563 // ----------------------------------------------------------------------------- |
|
1564 // CMceSession::SendRequestL |
|
1565 // ----------------------------------------------------------------------------- |
|
1566 // |
|
1567 EXPORT_C TMceTransactionId CMceSession::SendRequestL( const TDesC8& aMethod, |
|
1568 CDesC8Array* aHeaders, |
|
1569 HBufC8* aContentType, |
|
1570 HBufC8* aContent ) |
|
1571 { |
|
1572 MCECLI_DEBUG("CMceSession::SendRequestL, Entry") |
|
1573 TState state = State(); |
|
1574 MCECLI_DEBUG_CLISTATE( "state", state ) |
|
1575 |
|
1576 User::LeaveIfError( IsZombie() ? KErrArgument : KErrNone ); |
|
1577 |
|
1578 TCleanupItem sipParamsCleanup( SIPParamsCleanup, this ); |
|
1579 CleanupStack::PushL( sipParamsCleanup ); |
|
1580 |
|
1581 TMceIds ids; |
|
1582 PrepareForITC( ids ); |
|
1583 ids.iState = State(); |
|
1584 |
|
1585 HBufC8* method = aMethod.AllocLC(); |
|
1586 |
|
1587 CMceMsgSIPRequest* msg = |
|
1588 new (ELeave) CMceMsgSIPRequest( *method, *aHeaders, *aContentType ); |
|
1589 CleanupStack::PushL( msg ); |
|
1590 // Don't pass aContent's ownership. Delete it when this function can't leave |
|
1591 // anymore |
|
1592 iSender->SendL( ids, EMceItcRequestSend, *msg, aContent, EFalse ); |
|
1593 CleanupStack::PopAndDestroy( msg ); |
|
1594 CleanupStack::PopAndDestroy( method ); |
|
1595 |
|
1596 FLAT_DATA( iState ) = static_cast<TState>( ids.iState ); |
|
1597 |
|
1598 if ( ids.iStatus != KErrNone ) |
|
1599 { |
|
1600 MCECLI_DEBUG("CMceSession::SendInfoRequestL, info failed. rollback") |
|
1601 TMceIds ids2; |
|
1602 SynchronizeL( ids2 ); |
|
1603 state = State(); |
|
1604 MCECLI_DEBUG_CLISTATE( |
|
1605 "CMceSession::SendInfoRequestL, after ITC, state", state ) |
|
1606 CleanupStack::Pop(); // sipParamsCleanup |
|
1607 |
|
1608 MMceTransactionObserver* observer = iManager->TransactionObserver(); |
|
1609 if ( observer ) |
|
1610 { |
|
1611 observer->TransactionFailed( *this, ids.iTransactionID, ids.iStatus ); |
|
1612 } |
|
1613 } |
|
1614 else |
|
1615 { |
|
1616 CleanupStack::Pop(); // sipParamsCleanup |
|
1617 } |
|
1618 |
|
1619 delete aHeaders; |
|
1620 delete aContentType; |
|
1621 delete aContent; |
|
1622 |
|
1623 MCECLI_DEBUG("CMceSession::SendRequestL, Exit") |
|
1624 return ids.iTransactionID; |
|
1625 } |
|
1626 |
|
1627 // ----------------------------------------------------------------------------- |
|
1628 // CMceSession::SendResponseL |
|
1629 // ----------------------------------------------------------------------------- |
|
1630 // |
|
1631 EXPORT_C void CMceSession::SendResponseL( TMceTransactionId aTransactionId, |
|
1632 const TDesC8& aReason, |
|
1633 TUint32 aCode, |
|
1634 CDesC8Array* aHeaders, |
|
1635 HBufC8* aContentType, |
|
1636 HBufC8* aContent ) |
|
1637 { |
|
1638 MCECLI_DEBUG("CMceSession::SendResponseL, Entry") |
|
1639 TState state = State(); |
|
1640 MCECLI_DEBUG_CLISTATE( "state", state ) |
|
1641 |
|
1642 User::LeaveIfError( State() != CMceSession::EEstablished ); |
|
1643 |
|
1644 TCleanupItem sipParamsCleanup( SIPParamsCleanup, this ); |
|
1645 CleanupStack::PushL( sipParamsCleanup ); |
|
1646 |
|
1647 TMceIds ids; |
|
1648 PrepareForITC( ids ); |
|
1649 ids.iState = State(); |
|
1650 ids.iTransactionID = aTransactionId; |
|
1651 |
|
1652 HBufC8* reason = aReason.AllocLC(); |
|
1653 CMceMsgSIPReply* msg = new ( ELeave ) CMceMsgSIPReply( aTransactionId, |
|
1654 *reason, |
|
1655 aCode, |
|
1656 *aHeaders, |
|
1657 *aContentType ); |
|
1658 CleanupStack::PushL( msg ); |
|
1659 // Don't pass aContent's ownership. Delete it when this function can't leave |
|
1660 // anymore |
|
1661 iSender->SendL( ids, EMceItcReplySend, *msg, aContent, EFalse ); |
|
1662 CleanupStack::PopAndDestroy( msg ); |
|
1663 CleanupStack::PopAndDestroy( reason ); |
|
1664 |
|
1665 FLAT_DATA( iState ) = static_cast<TState>( ids.iState ); |
|
1666 MCECLI_DEBUG_CLISTATE( "CMceSession::SendResponseL, after ITC, state", state ) |
|
1667 |
|
1668 if ( ids.iStatus != KErrNone ) |
|
1669 { |
|
1670 MCECLI_DEBUG( "CMceSession::SendInfoRequestL, info failed. rollback" ) |
|
1671 |
|
1672 TMceIds ids2; |
|
1673 SynchronizeL( ids2 ); |
|
1674 state = State(); |
|
1675 MCECLI_DEBUG_CLISTATE( |
|
1676 "CMceSession::SendInfoRequestL, after ITC, state", state ) |
|
1677 |
|
1678 CleanupStack::Pop(); // sipParamsCleanup |
|
1679 |
|
1680 MMceTransactionObserver* observer = iManager->TransactionObserver(); |
|
1681 if ( observer ) |
|
1682 { |
|
1683 // Pass the proper Error Event to the Client.. |
|
1684 observer->TransactionFailed( *this, ids.iTransactionID, KErrNone ); |
|
1685 } |
|
1686 } |
|
1687 else |
|
1688 { |
|
1689 CleanupStack::Pop(); // sipParamsCleanup |
|
1690 } |
|
1691 |
|
1692 delete aHeaders; |
|
1693 delete aContentType; |
|
1694 delete aContent; |
|
1695 |
|
1696 MCECLI_DEBUG("CMceSession::SendInfoL, Exit") |
|
1697 } |
|
1698 |
|
1699 // End of File |