30 #include <sipacceptheader.h> |
30 #include <sipacceptheader.h> |
31 #include <sipstrings.h> |
31 #include <sipstrings.h> |
32 #include <sipstrconsts.h> |
32 #include <sipstrconsts.h> |
33 #include <sipresponseelements.h> |
33 #include <sipresponseelements.h> |
34 #include <sipaddress.h> |
34 #include <sipaddress.h> |
|
35 #include <sipfromheader.h> |
35 #include <sdpdocument.h> |
36 #include <sdpdocument.h> |
36 #include <sdporiginfield.h> |
37 #include <sdporiginfield.h> |
37 #include <sdpconnectionfield.h> |
38 #include <sdpconnectionfield.h> |
38 #include <sdpattributefield.h> |
39 #include <sdpattributefield.h> |
39 #include <sdpmediafield.h> |
40 #include <sdpmediafield.h> |
40 #include <e32math.h> |
41 #include <e32math.h> |
41 |
42 #include <e32property.h> |
42 |
43 |
43 #include "mussettings.h" |
44 #include "mussettings.h" |
44 #include "muslogger.h" |
45 #include "muslogger.h" |
45 #include "mmusavacapabilityqueryobserver.h" |
46 #include "mmusavacapabilityqueryobserver.h" |
46 #include "musavacapability.h" |
47 #include "musavacapability.h" |
47 #include "musavacapabilityexchange.h" |
48 #include "musavacapabilityexchange.h" |
48 #include "musavaterminal.h" |
49 #include "musavaterminal.h" |
49 #include "musavacapabilitycontext.h" |
50 #include "musavacapabilitycontext.h" |
50 #include "musavasipheaderutil.h" |
51 #include "musavasipheaderutil.h" |
|
52 #include "mussesseioninformationapi.h" |
|
53 |
|
54 _LIT8( KMusSipPrefix, "sip:" ); |
|
55 _LIT8( KMusTelPrefix, "tel:" ); |
|
56 _LIT8( KMusPlusSign, "+" ); |
|
57 _LIT8( KMusAtSign, "@" ); |
|
58 |
|
59 const TInt KMusMinDigitCountInTelNumber = 7; |
51 |
60 |
52 // -------------------------------------------------------------------------- |
61 // -------------------------------------------------------------------------- |
53 // C++ constructor |
62 // C++ constructor |
54 // -------------------------------------------------------------------------- |
63 // -------------------------------------------------------------------------- |
55 // |
64 // |
150 iOriginator = CUri8::NewL(sipAddress->Uri8().Uri()); |
159 iOriginator = CUri8::NewL(sipAddress->Uri8().Uri()); |
151 MUS_LOG_TDESC8( " mus: [MUSAVA] iOriginator : ", (iOriginator->Uri().UriDes())); |
160 MUS_LOG_TDESC8( " mus: [MUSAVA] iOriginator : ", (iOriginator->Uri().UriDes())); |
152 CleanupStack::PopAndDestroy(sipAddress); |
161 CleanupStack::PopAndDestroy(sipAddress); |
153 |
162 |
154 HBufC8* sipAddress8 = EscapeUtils::ConvertFromUnicodeToUtf8L( aSipAddress ); |
163 HBufC8* sipAddress8 = EscapeUtils::ConvertFromUnicodeToUtf8L( aSipAddress ); |
|
164 iRemoteUri.Copy( sipAddress8->Des() ) ; |
155 CleanupStack::PushL( sipAddress8 ); |
165 CleanupStack::PushL( sipAddress8 ); |
156 iTerminal = &Capability().Exchange().TerminalL( sipAddress8->Des() ); |
166 iTerminal = &Capability().Exchange().TerminalL( sipAddress8->Des() ); |
157 CleanupStack::PopAndDestroy( sipAddress8 ) ; |
167 CleanupStack::PopAndDestroy( sipAddress8 ) ; |
158 iTerminal->AttachQuery( *this ); |
168 iTerminal->AttachQuery( *this ); |
159 |
169 |
228 MUS_LOG( "mus: [MUSAVA] AddAcceptSDPHeaderL -> Success ") |
238 MUS_LOG( "mus: [MUSAVA] AddAcceptSDPHeaderL -> Success ") |
229 CMusAvaSipheaderUtil::AddPreferredIdentityHeaderL(headers, |
239 CMusAvaSipheaderUtil::AddPreferredIdentityHeaderL(headers, |
230 iOriginator->Uri().UriDes()); |
240 iOriginator->Uri().UriDes()); |
231 MUS_LOG( "mus: [MUSAVA] AddPreferredIdentityHeaderL -> Success ") |
241 MUS_LOG( "mus: [MUSAVA] AddPreferredIdentityHeaderL -> Success ") |
232 AddContactHeaderL( headers ); |
242 AddContactHeaderL( headers ); |
233 MUS_LOG( "mus: [MUSAVA] AddContactHeaderL -> Success ") |
243 MUS_LOG( "mus: [MUSAVA] AddContactHeaderL -> Success ") |
|
244 |
|
245 TBool usePrivacy = MultimediaSharingSettings::PrivacySetting(); |
|
246 if ( usePrivacy ) |
|
247 { |
|
248 NMusSessionInformationApi::TMusClirSetting clir = |
|
249 NMusSessionInformationApi::ESendOwnNumber; |
|
250 RProperty::Get( NMusSessionInformationApi::KCategoryUid, |
|
251 NMusSessionInformationApi::KMusClirSetting, |
|
252 reinterpret_cast<TInt&>( clir ) ); |
|
253 usePrivacy = ( clir == NMusSessionInformationApi::EDoNotSendOwnNumber ); |
|
254 } |
|
255 |
|
256 if (usePrivacy) |
|
257 { |
|
258 CMusAvaSipheaderUtil::AddPrivacyHeaderL( headers ); |
|
259 MUS_LOG( "mus: [MUSAVA] AddPrivacyHeaderL -> Success ") |
|
260 } |
234 //terminal ID |
261 //terminal ID |
235 if ( Capability().Exchange().TerminalId().Length() > 0 ) |
262 if ( Capability().Exchange().TerminalId().Length() > 0 ) |
236 { |
263 { |
237 MUS_LOG( "mus: [MUSAVA] Adding User-Agent header" ) |
264 MUS_LOG( "mus: [MUSAVA] Adding User-Agent header" ) |
238 CSIPHeaderBase* userAgent = |
265 CSIPHeaderBase* userAgent = |
249 CSIPRequestElements* request = |
276 CSIPRequestElements* request = |
250 CSIPRequestElements::NewL( remoteUri ); |
277 CSIPRequestElements::NewL( remoteUri ); |
251 CleanupStack::Pop( remoteUri ); |
278 CleanupStack::Pop( remoteUri ); |
252 CleanupStack::PushL( request ); |
279 CleanupStack::PushL( request ); |
253 |
280 |
|
281 if (usePrivacy) |
|
282 { |
|
283 _LIT8( KAnonymous, |
|
284 "\"Anonymous\" <sip:anonymous@anonymous.invalid>" ); |
|
285 CSIPFromHeader* from = CSIPFromHeader::DecodeL( KAnonymous ); |
|
286 CleanupStack::PushL( from ); |
|
287 request->SetFromHeaderL( from ); |
|
288 CleanupStack::Pop( from ); |
|
289 } |
|
290 |
254 request->SetMethodL( |
291 request->SetMethodL( |
255 SIPStrings::StringF( SipStrConsts::EOptions ) ); |
292 SIPStrings::StringF( SipStrConsts::EOptions ) ); |
256 |
293 |
257 CSIPMessageElements& message = request->MessageElements(); |
294 CSIPMessageElements& message = request->MessageElements(); |
258 message.SetUserHeadersL( headers ); |
295 message.SetUserHeadersL( headers ); |
468 |
505 |
469 MUS_LOG( "mus: [MUSAVA] Adding application attribute to SDP" ) |
506 MUS_LOG( "mus: [MUSAVA] Adding application attribute to SDP" ) |
470 //application |
507 //application |
471 CSdpAttributeField* application = CSdpAttributeField::NewLC( |
508 CSdpAttributeField* application = CSdpAttributeField::NewLC( |
472 MusAvaCapabilityContext::SDPStringL( |
509 MusAvaCapabilityContext::SDPStringL( |
473 SdpCodecStringConstants::EMediaApplication ), |
510 SdpCodecStringConstants::EMediaApplication ), |
474 KCapabilitySwisApplication ); |
511 KCapabilitySwisApplication ); |
475 |
512 |
476 aResponseContent.AttributeFields().AppendL( application ); |
513 aResponseContent.AttributeFields().AppendL( application ); |
477 CleanupStack::Pop( application ); |
514 CleanupStack::Pop( application ); |
478 |
515 |
487 CleanupStack::PushL( type ); |
524 CleanupStack::PushL( type ); |
488 |
525 |
489 aResponseContent.AttributeFields().AppendL( type ); |
526 aResponseContent.AttributeFields().AppendL( type ); |
490 CleanupStack::Pop( type ); |
527 CleanupStack::Pop( type ); |
491 |
528 |
492 // Fast startup mode |
|
493 CMusAvaCapability::AddFastModeL( aResponseContent ); |
|
494 |
|
495 MUS_LOG( "mus: [MUSAVA] Adding media line to SDP" ) |
529 MUS_LOG( "mus: [MUSAVA] Adding media line to SDP" ) |
496 //media line |
530 //media line |
497 CSdpMediaField* mediaLine = CSdpMediaField::NewLC( |
531 CSdpMediaField* mediaLine=CSdpMediaField::NewLC( |
498 MusAvaCapabilityContext::SDPStringL |
532 MusAvaCapabilityContext::SDPStringL |
499 (SdpCodecStringConstants::EMediaVideo ), |
533 (SdpCodecStringConstants::EMediaVideo ), |
500 NULL, |
534 NULL, |
501 MusAvaCapabilityContext::SDPStringL |
535 MusAvaCapabilityContext::SDPStringL |
502 (SdpCodecStringConstants::EProtocolRtpAvp ), |
536 (SdpCodecStringConstants::EProtocolRtpAvp ), |
503 KCapabilitySwisFormatListH263Only ); |
537 KCapabilitySwisFormatListH263Only ); |
504 |
538 |
505 //adding H.264 codec to SDP |
539 //adding H.264 codec to SDP |
506 if( !MultimediaSharingSettings::IsAvcDisabled()) |
540 if( !MultimediaSharingSettings::IsAvcDisabled()) |
536 CleanupStack::Pop( rtpMapH263 ); |
570 CleanupStack::Pop( rtpMapH263 ); |
537 |
571 |
538 aResponseContent.MediaFields().AppendL( mediaLine ); |
572 aResponseContent.MediaFields().AppendL( mediaLine ); |
539 CleanupStack::Pop( mediaLine ); |
573 CleanupStack::Pop( mediaLine ); |
540 |
574 |
|
575 |
541 MUS_LOG( "mus: [MUSAVA] <- CMusAvaCapabilityQueryBase::OtherSDPHeadersL" ) |
576 MUS_LOG( "mus: [MUSAVA] <- CMusAvaCapabilityQueryBase::OtherSDPHeadersL" ) |
542 } |
577 } |
543 |
578 |
544 |
579 // -------------------------------------------------------------------------- |
|
580 // CMusAvaCapabilityQueryBase::ValidateUri |
|
581 // -------------------------------------------------------------------------- |
|
582 // |
|
583 TBool CMusAvaCapabilityQueryBase::ValidateUri() |
|
584 { |
|
585 MUS_LOG( "mus: [MUSAVA] -> CMusAvaCapabilityQueryBase::ValidateUri" ) |
|
586 |
|
587 TBool valid = ETrue; |
|
588 |
|
589 const TDesC8& originator = iOriginator->Uri().UriDes(); |
|
590 MUS_LOG_TDESC8( "mus: [MUSAVA] originator uri: ", originator ) |
|
591 |
|
592 TBuf8<KMaxRemoteUriLength> sipUri; |
|
593 TBuf8<KMaxRemoteUriLength> telUri; |
|
594 |
|
595 if ( iRemoteUri.FindF( KMusSipPrefix ) != KErrNotFound ) |
|
596 { |
|
597 sipUri.Copy( iRemoteUri ); |
|
598 MUS_LOG_TDESC8( "mus: [MUSAVA] sip uri: ", sipUri ) |
|
599 } |
|
600 else if ( iRemoteUri.FindF( KMusTelPrefix ) != KErrNotFound ) |
|
601 { |
|
602 telUri.Copy( iRemoteUri ); |
|
603 MUS_LOG_TDESC8( "mus: [MUSAVA] tel uri: ", telUri ) |
|
604 } |
|
605 |
|
606 // Tel Uri case |
|
607 if ( telUri.Length() > 0 ) |
|
608 { |
|
609 telUri.Trim(); |
|
610 |
|
611 // Remove prefix and plus sign from remote uri if there is |
|
612 TPtrC8 telUriWithoutPrefix = |
|
613 telUri.Right( telUri.Length() - KMusTelPrefix().Length() ); |
|
614 MUS_LOG_TDESC8( "mus: [MUSAVA] telUriWithoutPrefix: ", telUriWithoutPrefix ) |
|
615 |
|
616 TPtrC8 numberPartOfTelUri = |
|
617 telUriWithoutPrefix.Find( KMusPlusSign ) == 0 ? |
|
618 telUriWithoutPrefix.Right( telUriWithoutPrefix.Length() - 1 ) : |
|
619 telUriWithoutPrefix; |
|
620 MUS_LOG_TDESC8( "mus: [MUSAVA] numberPartOfTelUri: ", numberPartOfTelUri ) |
|
621 |
|
622 // Remove prefix and domain part from uri in profile |
|
623 TPtrC8 originatorWithoutPrefix = |
|
624 originator.Right( originator.Length() - KMusSipPrefix().Length() ); |
|
625 MUS_LOG_TDESC8( "mus: [MUSAVA] originatorWithoutPrefix: ", originatorWithoutPrefix ) |
|
626 |
|
627 TPtrC8 usernameOfOriginator = |
|
628 originatorWithoutPrefix.Find( KMusPlusSign ) == 0 ? |
|
629 originatorWithoutPrefix.Right( originatorWithoutPrefix.Length() - 1 ) : |
|
630 originatorWithoutPrefix; |
|
631 |
|
632 TInt posOfAtSign = originatorWithoutPrefix.Find( KMusAtSign ); |
|
633 |
|
634 if ( posOfAtSign >= KMusMinDigitCountInTelNumber ) |
|
635 { |
|
636 usernameOfOriginator.Set( |
|
637 originatorWithoutPrefix.Mid( (originatorWithoutPrefix.Find( KMusAtSign ) |
|
638 - KMusMinDigitCountInTelNumber), KMusMinDigitCountInTelNumber ) ); |
|
639 MUS_LOG_TDESC8( "mus: [MUSAVA] usernameOfOriginator: ", usernameOfOriginator ) |
|
640 } |
|
641 |
|
642 else |
|
643 { |
|
644 usernameOfOriginator.Set( originatorWithoutPrefix.Left( posOfAtSign ) ); |
|
645 MUS_LOG_TDESC8( "mus: [MUSAVA] usernameOfOriginator: ", usernameOfOriginator ) |
|
646 } |
|
647 |
|
648 if ( numberPartOfTelUri.Length() >= KMusMinDigitCountInTelNumber ) |
|
649 { |
|
650 numberPartOfTelUri.Set( numberPartOfTelUri.Right( KMusMinDigitCountInTelNumber ) ); |
|
651 MUS_LOG_TDESC8( "mus: [MUSAVA] numberPartOfTelUri: ", numberPartOfTelUri ) |
|
652 } |
|
653 |
|
654 |
|
655 if ( numberPartOfTelUri == usernameOfOriginator ) |
|
656 { |
|
657 MUS_LOG( "mus: Recipient address is evaluated to be same as in profile.\ |
|
658 We do not send OPTIONS") |
|
659 valid = EFalse; |
|
660 MUS_LOG( "mus: [MUSAVA] <- CMusAvaCapabilityQueryBase::ValidateUri" ) |
|
661 return valid; |
|
662 } |
|
663 } |
|
664 |
|
665 // SIP Uri case |
|
666 if ( sipUri.Length() > 0 ) |
|
667 { |
|
668 if ( !originator.Compare( sipUri ) ) |
|
669 { |
|
670 MUS_LOG( "mus: Recipient address is evaluated to be same as in profile.\ |
|
671 We do not send OPTIONS") |
|
672 valid = EFalse; |
|
673 MUS_LOG( "mus: [MUSAVA] <- CMusAvaCapabilityQueryBase::ValidateUri" ) |
|
674 return valid; |
|
675 } |
|
676 } |
|
677 |
|
678 MUS_LOG( "mus: [MUSAVA] <- CMusAvaCapabilityQueryBase::ValidateUri" ) |
|
679 return valid; |
|
680 } |
|
681 |
|
682 |