31 |
31 |
32 // If EnableL fails a timeout for reporting error |
32 // If EnableL fails a timeout for reporting error |
33 const TInt KEnableTimeout = 120000000; |
33 const TInt KEnableTimeout = 120000000; |
34 |
34 |
35 const TInt KUsernameMaxLength = 255; |
35 const TInt KUsernameMaxLength = 255; |
|
36 |
|
37 _LIT8( KSCPAt8, "@" ); |
36 |
38 |
37 // ----------------------------------------------------------------------------- |
39 // ----------------------------------------------------------------------------- |
38 // CScpSipConnection::CScpSipConnection |
40 // CScpSipConnection::CScpSipConnection |
39 // ----------------------------------------------------------------------------- |
41 // ----------------------------------------------------------------------------- |
40 // |
42 // |
565 TInt CScpSipConnection::GetUsername( TDes8& aUsername ) const |
567 TInt CScpSipConnection::GetUsername( TDes8& aUsername ) const |
566 { |
568 { |
567 SCPLOGSTRING2( "CScpSipConnection[0x%x]::GetUsername", this ); |
569 SCPLOGSTRING2( "CScpSipConnection[0x%x]::GetUsername", this ); |
568 |
570 |
569 TInt result( KErrNotFound ); |
571 TInt result( KErrNotFound ); |
|
572 |
|
573 // Check if profile is registered |
|
574 TBool val( EFalse ); |
|
575 result = iSipProfile->GetParameter( KSIPProfileRegistered, val ); |
|
576 |
570 const TDesC8* aor( NULL ); |
577 const TDesC8* aor( NULL ); |
571 |
578 |
572 // Get SIP's Username |
579 // Get SIP's Username |
573 result = iSipProfile->GetParameter( KSIPUserAor, aor ); |
580 result = iSipProfile->GetParameter( KSIPUserAor, aor ); |
574 |
581 |
575 if ( result == KErrNone && aor ) |
582 if ( result == KErrNone && aor->Length() > KErrNone ) |
576 { |
583 { |
577 if ( aor->Length() <= aUsername.MaxLength() ) |
584 if ( aor->Length() <= aUsername.MaxLength() ) |
578 { |
585 { |
|
586 SCPLOGSTRING( "CScpSipConnection::GetUsername - Got username from AOR" ); |
579 aUsername.Copy( *aor ); |
587 aUsername.Copy( *aor ); |
580 } |
588 } |
581 else |
589 else |
582 { |
590 { |
|
591 SCPLOGSTRING( "CScpSipConnection::GetUsername - KErrOverflow" ); |
583 result = KErrOverflow; |
592 result = KErrOverflow; |
584 } |
593 } |
585 } |
594 } |
586 |
595 else if ( val ) // registered |
|
596 { |
|
597 // Might be IMS case and UserAor is incomplete, then |
|
598 // Get SIP's Username from registered AORs |
|
599 const MDesC8Array* aors = 0; |
|
600 result = iSipProfile->GetParameter( KSIPRegisteredAors, aors ); |
|
601 if ( !aors || aors->MdcaCount() == 0 ) |
|
602 { |
|
603 SCPLOGSTRING( "CScpSipConnection::GetUsername - KErrNotReady" ); |
|
604 result = KErrNotReady; |
|
605 } |
|
606 else |
|
607 { |
|
608 HBufC8* tmpUserName = HBufC8::NewLC( aors->MdcaPoint( 0 ).Length() ); |
|
609 tmpUserName->Des().Copy( aors->MdcaPoint( 0 ) ); |
|
610 #ifdef _DEBUG |
|
611 TBuf<256> tmpUri; |
|
612 tmpUri.Copy( aors->MdcaPoint( 0 ) ); |
|
613 SCPLOGSTRING2( "CScpSipConnection::GetUsername - use first registered AOR: %S", &tmpUri ); |
|
614 #endif |
|
615 TInt atPos = tmpUserName->Find( KSCPAt8 ); |
|
616 aUsername.Copy( tmpUserName->Left( atPos ) ); |
|
617 CleanupStack::PopAndDestroy( tmpUserName ); |
|
618 } |
|
619 } |
|
620 SCPLOGSTRING2( "CScpSipConnection::GetUsername - return error: %d", result ); |
587 return result; |
621 return result; |
588 } |
622 } |
589 |
623 |
590 // ----------------------------------------------------------------------------- |
624 // ----------------------------------------------------------------------------- |
591 // CScpSipConnection::GetDomain |
625 // CScpSipConnection::GetDomain |