49 #include "musavaterminal.h" |
49 #include "musavaterminal.h" |
50 #include "musavacapabilitycontext.h" |
50 #include "musavacapabilitycontext.h" |
51 #include "musavasipheaderutil.h" |
51 #include "musavasipheaderutil.h" |
52 #include "mussesseioninformationapi.h" |
52 #include "mussesseioninformationapi.h" |
53 |
53 |
|
54 _LIT8( KMusSipPrefix, "sip:" ); |
|
55 _LIT8( KMusTelPrefix, "tel:" ); |
|
56 _LIT8( KMusPlusSign, "+" ); |
|
57 _LIT8( KMusAtSign, "@" ); |
|
58 |
|
59 const TInt KMusMinDigitCountInTelNumber = 7; |
|
60 |
54 // -------------------------------------------------------------------------- |
61 // -------------------------------------------------------------------------- |
55 // C++ constructor |
62 // C++ constructor |
56 // -------------------------------------------------------------------------- |
63 // -------------------------------------------------------------------------- |
57 // |
64 // |
58 CMusAvaCapabilityQueryBase::CMusAvaCapabilityQueryBase( |
65 CMusAvaCapabilityQueryBase::CMusAvaCapabilityQueryBase( |
152 iOriginator = CUri8::NewL(sipAddress->Uri8().Uri()); |
159 iOriginator = CUri8::NewL(sipAddress->Uri8().Uri()); |
153 MUS_LOG_TDESC8( " mus: [MUSAVA] iOriginator : ", (iOriginator->Uri().UriDes())); |
160 MUS_LOG_TDESC8( " mus: [MUSAVA] iOriginator : ", (iOriginator->Uri().UriDes())); |
154 CleanupStack::PopAndDestroy(sipAddress); |
161 CleanupStack::PopAndDestroy(sipAddress); |
155 |
162 |
156 HBufC8* sipAddress8 = EscapeUtils::ConvertFromUnicodeToUtf8L( aSipAddress ); |
163 HBufC8* sipAddress8 = EscapeUtils::ConvertFromUnicodeToUtf8L( aSipAddress ); |
|
164 iRemoteUri.Copy( sipAddress8->Des() ) ; |
157 CleanupStack::PushL( sipAddress8 ); |
165 CleanupStack::PushL( sipAddress8 ); |
158 iTerminal = &Capability().Exchange().TerminalL( sipAddress8->Des() ); |
166 iTerminal = &Capability().Exchange().TerminalL( sipAddress8->Des() ); |
159 CleanupStack::PopAndDestroy( sipAddress8 ) ; |
167 CleanupStack::PopAndDestroy( sipAddress8 ) ; |
160 iTerminal->AttachQuery( *this ); |
168 iTerminal->AttachQuery( *this ); |
161 |
169 |
566 |
574 |
567 |
575 |
568 MUS_LOG( "mus: [MUSAVA] <- CMusAvaCapabilityQueryBase::OtherSDPHeadersL" ) |
576 MUS_LOG( "mus: [MUSAVA] <- CMusAvaCapabilityQueryBase::OtherSDPHeadersL" ) |
569 } |
577 } |
570 |
578 |
571 |
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 |