|
1 /* |
|
2 * Copyright (c) 2005-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: Discovered terminal |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "musavaterminal.h" |
|
20 |
|
21 #include <escapeutils.h> |
|
22 #include <uri8.h> |
|
23 #include <sip.h> |
|
24 #include <sipconnection.h> |
|
25 #include <sipservertransaction.h> |
|
26 #include <sipclienttransaction.h> |
|
27 #include <sipheaderbase.h> |
|
28 #include <sipextensionheader.h> |
|
29 #include <sdpdocument.h> |
|
30 #include <sipcontenttypeheader.h> |
|
31 #include <sipmessageelements.h> |
|
32 #include <sipresponseelements.h> |
|
33 #include <siprequestelements.h> |
|
34 #include <sipstrings.h> |
|
35 #include <sipstrconsts.h> |
|
36 #include <sipcontactheader.h> |
|
37 #include <sipaddress.h> |
|
38 |
|
39 #include "muslogger.h" |
|
40 #include "musavacapabilityexchange.h" |
|
41 #include "musavacapability.h" |
|
42 #include "musavacapabilityquerybase.h" |
|
43 #include "musavacapabilitycontext.h" |
|
44 #include "mmusavacapabilityqueryobserver.h" |
|
45 #include "mussettings.h" |
|
46 #include "mussettingskeys.h" |
|
47 #include "musavasipheaderutil.h" |
|
48 |
|
49 // -------------------------------------------------------------------------- |
|
50 // Symbian two-phase constructor |
|
51 // -------------------------------------------------------------------------- |
|
52 // |
|
53 CMusAvaTerminal* CMusAvaTerminal::NewL( CMusAvaCapabilityExchange& aExchange, |
|
54 const TDesC8& aTerminalUri, |
|
55 const TDesC8& aTerminalId ) |
|
56 { |
|
57 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::NewL" ) |
|
58 CMusAvaTerminal* self = new (ELeave) CMusAvaTerminal( aExchange ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL( aTerminalUri, aTerminalId ); |
|
61 CleanupStack::Pop( self ); |
|
62 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::NewL" ) |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 // -------------------------------------------------------------------------- |
|
68 // C++ destructor |
|
69 // -------------------------------------------------------------------------- |
|
70 // |
|
71 CMusAvaTerminal::~CMusAvaTerminal() |
|
72 { |
|
73 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::~CMusAvaTerminal" ) |
|
74 |
|
75 ResetAndDestroyQuery(); |
|
76 |
|
77 delete iUri; |
|
78 delete iTerminalId; |
|
79 iRequestedQuery = NULL; |
|
80 |
|
81 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::~CMusAvaTerminal" ) |
|
82 } |
|
83 |
|
84 // -------------------------------------------------------------------------- |
|
85 // C++ constructor |
|
86 // -------------------------------------------------------------------------- |
|
87 // |
|
88 CMusAvaTerminal::CMusAvaTerminal( CMusAvaCapabilityExchange& aExchange ) |
|
89 : iExchange( aExchange ) |
|
90 { |
|
91 } |
|
92 |
|
93 |
|
94 // -------------------------------------------------------------------------- |
|
95 // Symbian second-phase constructor |
|
96 // -------------------------------------------------------------------------- |
|
97 // |
|
98 void CMusAvaTerminal::ConstructL( const TDesC8& aTerminalUri, |
|
99 const TDesC8& aTerminalId ) |
|
100 { |
|
101 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::ConstructL" ) |
|
102 |
|
103 MUS_LOG_TDESC8( "mus: [MUSAVA] - CMusAvaTerminal::Id ",aTerminalId) |
|
104 MUS_LOG_TDESC8( "mus: [MUSAVA] - CMusAvaTerminal::MatchL Uri",aTerminalUri ) |
|
105 iUri = aTerminalUri.AllocL(); |
|
106 iTerminalId = aTerminalId.AllocL(); |
|
107 |
|
108 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::ConstructL" ) |
|
109 } |
|
110 |
|
111 |
|
112 // -------------------------------------------------------------------------- |
|
113 // CMusAvaTerminal::Id |
|
114 // -------------------------------------------------------------------------- |
|
115 // |
|
116 const TDesC8& CMusAvaTerminal::Id() const |
|
117 { |
|
118 return *iTerminalId; |
|
119 } |
|
120 |
|
121 |
|
122 // -------------------------------------------------------------------------- |
|
123 // CMusAvaTerminal::ToUriL |
|
124 // -------------------------------------------------------------------------- |
|
125 // |
|
126 const TDesC8& CMusAvaTerminal::Uri() const |
|
127 { |
|
128 return *iUri; |
|
129 } |
|
130 |
|
131 |
|
132 // -------------------------------------------------------------------------- |
|
133 // CMusAvaTerminal::MacthL |
|
134 // -------------------------------------------------------------------------- |
|
135 // |
|
136 TBool CMusAvaTerminal::MatchL( const TDesC8& aTerminalUri, |
|
137 const TDesC8& aTerminalId ) |
|
138 { |
|
139 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::MatchL" ) |
|
140 TBool match = EFalse; |
|
141 TBool useDoubleKeyMatch = Id().Length() > 0 && aTerminalId.Length() > 0; |
|
142 |
|
143 MUS_LOG_TDESC8( "mus: [MUSAVA] - CMusAvaTerminal::MatchL aTerminalId ",aTerminalId ) |
|
144 MUS_LOG_TDESC8( "mus: [MUSAVA] - CMusAvaTerminal::MatchL aTerminalUri ",aTerminalUri ) |
|
145 if ( useDoubleKeyMatch ) |
|
146 { |
|
147 match = Uri().Compare( aTerminalUri ) == 0 && |
|
148 Id().CompareF( aTerminalId ) == 0; |
|
149 } |
|
150 else //not known yet or no terminal id in request i.e. best guess |
|
151 { |
|
152 match = Uri().Compare( aTerminalUri ) == 0; |
|
153 } |
|
154 |
|
155 if ( match ) |
|
156 { |
|
157 AttachUriL( aTerminalUri ); |
|
158 AttachIdL( aTerminalId ); |
|
159 } |
|
160 |
|
161 MUS_LOG1( "mus: [MUSAVA] <- CMusAvaTerminal::MatchL = %d",match ) |
|
162 return match; |
|
163 } |
|
164 |
|
165 |
|
166 // -------------------------------------------------------------------------- |
|
167 // CMusAvaTerminal::RequestedQuery |
|
168 // -------------------------------------------------------------------------- |
|
169 // |
|
170 const CMusAvaCapability* CMusAvaTerminal::RequestedQuery() const |
|
171 { |
|
172 return iRequestedQuery; |
|
173 } |
|
174 |
|
175 |
|
176 // -------------------------------------------------------------------------- |
|
177 // CMusAvaTerminal::ExecuteQueryL |
|
178 // -------------------------------------------------------------------------- |
|
179 // |
|
180 void CMusAvaTerminal::ExecuteQueryL( CMusAvaCapabilityQueryBase* aQuery ) |
|
181 { |
|
182 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::ExecuteQueryL" ) |
|
183 |
|
184 __ASSERT_ALWAYS( aQuery , User::Leave( KErrArgument ) ); |
|
185 __ASSERT_ALWAYS( |
|
186 aQuery->State() == CMusAvaCapabilityQueryBase::ECapabilityQueryCreated, |
|
187 User::Leave( KErrArgument ) ); |
|
188 __ASSERT_ALWAYS( !iQuery, User::Leave( KErrAlreadyExists ) ); |
|
189 |
|
190 ResetAndDestroyQuery(); |
|
191 |
|
192 aQuery->ExecuteL(); |
|
193 |
|
194 iQuery = aQuery; |
|
195 |
|
196 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::ExecuteQueryL" ) |
|
197 } |
|
198 |
|
199 |
|
200 // -------------------------------------------------------------------------- |
|
201 // CMusAvaTerminal::QueryCompletedL |
|
202 // -------------------------------------------------------------------------- |
|
203 // |
|
204 TBool CMusAvaTerminal::QueryCompletedL( const CSIPClientTransaction& aResponse ) |
|
205 { |
|
206 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::QueryCompletedL" ) |
|
207 TBool consumed = EFalse; |
|
208 |
|
209 if ( iQuery && iQuery->State() != |
|
210 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ) |
|
211 { |
|
212 iQuery->CompletedL( aResponse ); |
|
213 consumed = iQuery->State() == |
|
214 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted; |
|
215 |
|
216 if ( consumed ) |
|
217 { |
|
218 const CSIPExtensionHeader* userAgent = |
|
219 MusAvaCapabilityContext::UserAgentHeaderL( aResponse ); |
|
220 if ( userAgent ) |
|
221 { |
|
222 AttachIdL( userAgent->Value() ); |
|
223 } |
|
224 } |
|
225 } |
|
226 |
|
227 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::QueryCompletedL" ) |
|
228 |
|
229 return consumed; |
|
230 } |
|
231 |
|
232 |
|
233 // -------------------------------------------------------------------------- |
|
234 // CMusAvaTerminal::QueryCanceled |
|
235 // -------------------------------------------------------------------------- |
|
236 // |
|
237 TBool CMusAvaTerminal::QueryCanceled( |
|
238 const CSIPClientTransaction& aTransaction ) |
|
239 { |
|
240 TBool consumed = EFalse; |
|
241 if ( iQuery && iQuery->State() != |
|
242 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted ) |
|
243 { |
|
244 iQuery->Canceled( aTransaction ); |
|
245 consumed = iQuery->State() == |
|
246 CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted; |
|
247 } |
|
248 return consumed; |
|
249 } |
|
250 |
|
251 |
|
252 // -------------------------------------------------------------------------- |
|
253 // CMusAvaTerminal::QueryExecuting |
|
254 // -------------------------------------------------------------------------- |
|
255 // |
|
256 TBool CMusAvaTerminal::QueryExecuting() |
|
257 { |
|
258 TBool executing = EFalse; |
|
259 if ( iQuery && iQuery->State() == |
|
260 CMusAvaCapabilityQueryBase::ECapabilityQueryExecuting ) |
|
261 { |
|
262 executing = ETrue; |
|
263 } |
|
264 return executing; |
|
265 } |
|
266 |
|
267 |
|
268 // -------------------------------------------------------------------------- |
|
269 // CMusAvaTerminal::QueryRequestedL |
|
270 // -------------------------------------------------------------------------- |
|
271 // |
|
272 void CMusAvaTerminal::QueryRequestedL( CSIPServerTransaction& aQuery ) |
|
273 { |
|
274 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::QueryRequestedL" ) |
|
275 |
|
276 CSIPResponseElements* response = |
|
277 CSIPResponseElements::NewLC( |
|
278 KMUSAVASIP200, |
|
279 SIPStrings::StringF( SipStrConsts::EPhraseOk ) ); |
|
280 |
|
281 CSdpDocument* sdpContent = |
|
282 CMusAvaCapability::ResponseContentLC( aQuery ); |
|
283 |
|
284 RPointerArray<CSIPHeaderBase> headers; |
|
285 CSIPHeaderBase::PushLC( &headers ); |
|
286 |
|
287 if ( PopulateResponseL( aQuery, headers, *sdpContent ) ) |
|
288 { |
|
289 RStringF feature = |
|
290 MusAvaCapabilityContext::SIPStringL( KCapabilitySwisFeature ); |
|
291 CleanupClosePushL( feature ); |
|
292 CMusAvaSipheaderUtil::AddAcceptContactHeaderL( headers, |
|
293 feature ); |
|
294 CleanupStack::PopAndDestroy(); //feature |
|
295 MUS_LOG( "mus: [MUSAVA] AddAcceptContactHeaderL -> Success ") |
|
296 |
|
297 MUS_LOG( "mus: [MUSAVA] AddAcceptEncodingHeaderL -> Success ") |
|
298 |
|
299 MUS_LOG( "mus: [MUSAVA] AddAcceptLanguageHeaderL -> Success ") |
|
300 CMusAvaSipheaderUtil::AddAcceptSdpHeaderL(headers); |
|
301 MUS_LOG( "mus: [MUSAVA] AddAcceptSDPHeaderL -> Success ") |
|
302 AddResponseHeadersL( *response, headers ); |
|
303 CleanupStack::Pop( &headers ); |
|
304 AddResponseContentL( *response, *sdpContent ); |
|
305 } |
|
306 else |
|
307 { |
|
308 CleanupStack::PopAndDestroy( &headers ); |
|
309 response->SetStatusCodeL( KMUSAVASIPNotImplemented ); |
|
310 response->SetReasonPhraseL( |
|
311 SIPStrings::StringF( SipStrConsts::EPhraseNotImplemented ) ); |
|
312 } |
|
313 CleanupStack::PopAndDestroy( sdpContent ); |
|
314 |
|
315 MUS_LOG( "mus: [MUSAVA] -> Sending Response For Options Request ..." ) |
|
316 aQuery.SendResponseL( response ); |
|
317 CleanupStack::Pop( response ); |
|
318 |
|
319 iExchange.QueryObserver().CapabilityQueryAnswered( ETrue ); |
|
320 |
|
321 // Add sipaddress proposal |
|
322 if ( response->StatusCode( ) == KMUSAVASIP200 ) |
|
323 { |
|
324 |
|
325 const CSIPContactHeader* contact = |
|
326 MusAvaCapabilityContext::ContactHeaderL( aQuery ); |
|
327 |
|
328 if ( !contact ) |
|
329 { |
|
330 MUS_LOG( "mus: [MUSAVA] => FAILED due lack of contact header" ) |
|
331 } |
|
332 else |
|
333 { |
|
334 /* |
|
335 const TDesC8& uriInContact = |
|
336 contact->SIPAddress()->Uri8().Uri().UriDes(); |
|
337 if ( uriInContact.Length() > 0 ) |
|
338 { |
|
339 HBufC* uri = |
|
340 EscapeUtils::ConvertToUnicodeFromUtf8L( uriInContact ); |
|
341 CleanupStack::PushL( uri ); |
|
342 iExchange.QueryObserver().CapabilitiesResolvedL( *uri ); |
|
343 CleanupStack::PopAndDestroy( uri ); |
|
344 } |
|
345 */ |
|
346 |
|
347 // If there is P-Asserted-Identity header then send the OPTIONS |
|
348 // to this. Store it in settings data as To header so then future |
|
349 // request can be sent there. |
|
350 |
|
351 CDesCArrayFlat* pAssertedIdentityHeaders = |
|
352 MusAvaCapabilityContext::PAssertedIdentityHeaderL( |
|
353 MusAvaCapabilityContext::MessageElementsL(aQuery)); |
|
354 CleanupStack::PushL( pAssertedIdentityHeaders ); |
|
355 __ASSERT_ALWAYS(pAssertedIdentityHeaders,User::Leave(KErrArgument)); |
|
356 if(pAssertedIdentityHeaders->Count()>0) |
|
357 { |
|
358 iExchange.QueryObserver().SipHeadersL(*pAssertedIdentityHeaders, |
|
359 SipStrConsts::EToHeader); |
|
360 } |
|
361 else |
|
362 { |
|
363 // P-Asserted-Identity header not exist. So rely on other contacts |
|
364 // read from phone book or Tel URI to send request. |
|
365 } |
|
366 pAssertedIdentityHeaders->Reset(); |
|
367 CleanupStack::PopAndDestroy( pAssertedIdentityHeaders ); |
|
368 |
|
369 TBool sequential = |
|
370 MultimediaSharingSettings::OperatorVariantSettingL() == |
|
371 MusSettingsKeys::EOperatorSpecific || |
|
372 MusSettingsKeys::ESequential == |
|
373 MultimediaSharingSettings::CapabilityQuerySettingL(); |
|
374 |
|
375 TBool alreadyRequested = iExchange.QueryObserver(). |
|
376 CapabilitiesResolvedForCingular(); |
|
377 |
|
378 if ( sequential && !alreadyRequested ) |
|
379 { |
|
380 iExchange.QueryObserver().SetCapabilitiesResolvedForCingular(); |
|
381 } |
|
382 } |
|
383 } |
|
384 |
|
385 |
|
386 //if pending query |
|
387 if ( iQuery ) |
|
388 { |
|
389 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::QueryRequestedL Executing Pending Query" ) |
|
390 iQuery->ExecuteL(); |
|
391 } |
|
392 |
|
393 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::QueryRequestedL" ) |
|
394 } |
|
395 |
|
396 |
|
397 // -------------------------------------------------------------------------- |
|
398 // CMusAvaTerminal::AttachQuery |
|
399 // -------------------------------------------------------------------------- |
|
400 // |
|
401 TInt CMusAvaTerminal::AttachQuery( CMusAvaCapabilityQueryBase& /*aQuery*/ ) |
|
402 { |
|
403 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::AttachQuery" ) |
|
404 iQueries++; |
|
405 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::AttachQuery" ) |
|
406 return iQueries; |
|
407 } |
|
408 |
|
409 |
|
410 // -------------------------------------------------------------------------- |
|
411 // CMusAvaTerminal::DetachQuery |
|
412 // -------------------------------------------------------------------------- |
|
413 // |
|
414 TInt CMusAvaTerminal::DetachQuery( CMusAvaCapabilityQueryBase& /*aQuery*/ ) |
|
415 { |
|
416 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::DetachQuery" ) |
|
417 iQueries--; |
|
418 __ASSERT_ALWAYS( iQueries >= 0, |
|
419 User::Panic( _L("CMusAvaTerminal"), KErrGeneral ) ); |
|
420 |
|
421 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::DetachQuery" ) |
|
422 |
|
423 return iQueries; |
|
424 } |
|
425 |
|
426 |
|
427 // -------------------------------------------------------------------------- |
|
428 // CMusAvaTerminal::AttachIdL |
|
429 // -------------------------------------------------------------------------- |
|
430 // |
|
431 void CMusAvaTerminal::AttachIdL( const TDesC8& aTerminalId ) |
|
432 { |
|
433 if ( aTerminalId.Length() > 0 ) |
|
434 { |
|
435 //terminal id might change |
|
436 HBufC8* tmpTerminalId = aTerminalId.AllocL(); |
|
437 delete iTerminalId; |
|
438 iTerminalId = tmpTerminalId; |
|
439 } |
|
440 } |
|
441 |
|
442 |
|
443 // -------------------------------------------------------------------------- |
|
444 // CMusAvaTerminal::AttachUriL |
|
445 // -------------------------------------------------------------------------- |
|
446 // |
|
447 void CMusAvaTerminal::AttachUriL( const TDesC8& aUri ) |
|
448 { |
|
449 if ( aUri.Length() > 0 ) |
|
450 { |
|
451 delete iUri; |
|
452 iUri = NULL; |
|
453 iUri = aUri.AllocL(); |
|
454 } |
|
455 } |
|
456 |
|
457 |
|
458 // -------------------------------------------------------------------------- |
|
459 // CMusAvaTerminal::ResetAndDestroyQuery |
|
460 // -------------------------------------------------------------------------- |
|
461 // |
|
462 void CMusAvaTerminal::ResetAndDestroyQuery() |
|
463 { |
|
464 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::ResetAndDestroyQuery" ) |
|
465 CMusAvaCapabilityQueryBase* query = iQuery; |
|
466 iQuery = NULL; |
|
467 delete query; |
|
468 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::ResetAndDestroyQuery" ) |
|
469 } |
|
470 |
|
471 |
|
472 // -------------------------------------------------------------------------- |
|
473 // CMusAvaTerminal::PopulateResponseL |
|
474 // -------------------------------------------------------------------------- |
|
475 // |
|
476 TBool CMusAvaTerminal::PopulateResponseL( CSIPServerTransaction& aQuery, |
|
477 RPointerArray<CSIPHeaderBase>& aResponseHeaders, |
|
478 CSdpDocument& aSdpContent ) |
|
479 { |
|
480 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::PopulateResponseL" ) |
|
481 |
|
482 TBool supported = EFalse; |
|
483 |
|
484 const CSIPAcceptContactHeader* featureSet = |
|
485 MusAvaCapabilityContext::AcceptContactHeaderL( aQuery ); |
|
486 |
|
487 User::LeaveIfError( !featureSet ? KErrGeneral : KErrNone ); |
|
488 |
|
489 for( TInt i = 0; i < iExchange.Capabilities().Count();i++ ) |
|
490 { |
|
491 CMusAvaCapability* capability = iExchange.Capabilities()[ i ]; |
|
492 TBool containsFeature = capability->Supports( *featureSet ); |
|
493 supported = containsFeature ? ETrue : supported; |
|
494 |
|
495 if ( containsFeature ) |
|
496 { |
|
497 const CSIPMessageElements& elements = |
|
498 MusAvaCapabilityContext::MessageElementsL( aQuery ); |
|
499 const TDesC8& content = elements.Content(); |
|
500 CSdpDocument* sdp = NULL; |
|
501 |
|
502 if ( content.Length() > 0 ) |
|
503 { |
|
504 sdp = CSdpDocument::DecodeLC( content ); |
|
505 } |
|
506 else |
|
507 { |
|
508 sdp = CSdpDocument::NewLC(); |
|
509 } |
|
510 |
|
511 //store video codecs that came from the other terminal |
|
512 CDesCArrayFlat* videoCodecs = CMusAvaCapability::ResolveCodecsL( *sdp ); |
|
513 CleanupStack::PushL( videoCodecs ); |
|
514 capability->Exchange().QueryObserver().VideoCodecsResolvedL( *videoCodecs ); |
|
515 CleanupStack::PopAndDestroy( videoCodecs ); |
|
516 |
|
517 CleanupStack::PopAndDestroy( sdp ); |
|
518 |
|
519 capability->PopulateResponseL( aQuery, |
|
520 aResponseHeaders, |
|
521 aSdpContent ); |
|
522 iRequestedQuery = capability; |
|
523 } |
|
524 } |
|
525 |
|
526 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::PopulateResponseL" ) |
|
527 |
|
528 return supported; |
|
529 } |
|
530 |
|
531 |
|
532 // -------------------------------------------------------------------------- |
|
533 // CMusAvaTerminal::AddResponseHeadersL |
|
534 // -------------------------------------------------------------------------- |
|
535 // |
|
536 void CMusAvaTerminal::AddResponseHeadersL( CSIPResponseElements& aResponse, |
|
537 RPointerArray<CSIPHeaderBase>& aResponseHeaders ) |
|
538 { |
|
539 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::AddResponseHeadersL" ) |
|
540 |
|
541 CSIPMessageElements& message = aResponse.MessageElements(); |
|
542 |
|
543 if ( iExchange.TerminalId().Length() > 0 ) |
|
544 { |
|
545 //terminal id |
|
546 CSIPHeaderBase* userAgent = |
|
547 MusAvaCapabilityContext::UserAgentHeaderLC( |
|
548 iExchange.TerminalId() ); |
|
549 aResponseHeaders.AppendL( userAgent ); |
|
550 CleanupStack::Pop( userAgent ); |
|
551 } |
|
552 |
|
553 //Set user headers |
|
554 message.SetUserHeadersL( aResponseHeaders ); |
|
555 |
|
556 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::AddResponseHeadersL" ) |
|
557 } |
|
558 |
|
559 |
|
560 // -------------------------------------------------------------------------- |
|
561 // CMusAvaTerminal::AddResponseContentL |
|
562 // -------------------------------------------------------------------------- |
|
563 // |
|
564 void CMusAvaTerminal::AddResponseContentL( CSIPResponseElements& aResponse, |
|
565 CSdpDocument& aSdpContent ) |
|
566 { |
|
567 MUS_LOG( "mus: [MUSAVA] -> CMusAvaTerminal::AddResponseContentL" ) |
|
568 |
|
569 CSIPMessageElements& message = aResponse.MessageElements(); |
|
570 |
|
571 //create content from SDP document |
|
572 HBufC8* content = MusAvaCapabilityContext::ToTextL( aSdpContent ); |
|
573 CleanupStack::PushL( content ); |
|
574 |
|
575 //create content type |
|
576 CSIPContentTypeHeader* contentTypeHeader = NULL; |
|
577 contentTypeHeader = |
|
578 CSIPContentTypeHeader::NewLC( KMUSAVASIPMediaTypeApplication, |
|
579 KMUSAVASIPMediaSubTypeSDP ); |
|
580 |
|
581 //set content |
|
582 message.SetContentL( content, contentTypeHeader ); |
|
583 CleanupStack::Pop( contentTypeHeader ); |
|
584 CleanupStack::Pop( content ); |
|
585 |
|
586 MUS_LOG( "mus: [MUSAVA] <- CMusAvaTerminal::AddResponseContentL" ) |
|
587 } |
|
588 // -------------------------------------------------------------------------- |
|
589 // CMusAvaTerminal::IsDiscovered |
|
590 // -------------------------------------------------------------------------- |
|
591 // |
|
592 TBool CMusAvaTerminal::IsDiscovered() |
|
593 { |
|
594 TBool isDiscovered = EFalse; |
|
595 TBool isGarbage = !iQueries && !RequestedQuery(); |
|
596 |
|
597 if ( !isGarbage ) |
|
598 { |
|
599 isDiscovered = |
|
600 iQueries == 1 && |
|
601 iQuery && |
|
602 iQuery->State() == CMusAvaCapabilityQueryBase::ECapabilityQueryCompleted; |
|
603 } |
|
604 else |
|
605 { |
|
606 isDiscovered = ETrue; |
|
607 } |
|
608 |
|
609 return isDiscovered; |
|
610 |
|
611 } |