diff -r 7117cbf1600a -r bddb6d4447db voipplugins/svtmatching/src/svturiparser.cpp --- a/voipplugins/svtmatching/src/svturiparser.cpp Fri Mar 12 15:42:09 2010 +0200 +++ b/voipplugins/svtmatching/src/svturiparser.cpp Mon Mar 15 12:39:55 2010 +0200 @@ -95,81 +95,114 @@ const TDesC& aData, RBuf& aDisplayname ) const { - TInt ret( KErrNotFound ); + TInt result = KErrNotFound; + + TRAPD( err, DisplayNameFromUriL( aData, aDisplayname, result ) ); + if ( err ) + { + result = err; + } + return result; + } + +// --------------------------------------------------------------------------- +// The inner logic for resolving display name from sip uri +// --------------------------------------------------------------------------- +// +void CSvtUriParser::DisplayNameFromUriL( + const TDesC& aData, + RBuf& aDisplayname, + TInt& aResult ) const + { + aResult = KErrNotFound; - TPtrC resultStr( aData ); + TPtrC preResultStr( aData ); aDisplayname.Close(); - // resolves potential SIP Display info and removes it from uri - // also possible "<" and ">" character are removed around the SIP uri - TInt uriStartIndex = resultStr.LocateReverse( KStartBracket ); - TInt uriEndIndex = resultStr.LocateReverse( KEndBracket ); + HBufC* tempBuffer = preResultStr.AllocLC(); // CS:1 + tempBuffer->Des().TrimAll(); - if ( uriStartIndex > uriEndIndex ) + if ( tempBuffer->Length() ) { - // Start and end separators in wrong order: "xxxx>xxxxDes() ); + + // resolves potential SIP Display info and removes it from uri + // also possible "<" and ">" character are removed around the SIP uri + TInt uriStartIndex = resultStr.LocateReverse( KStartBracket ); + TInt uriEndIndex = resultStr.LocateReverse( KEndBracket ); - // check if there is anything before "<" if there is use - // it as displayname if match op fails. - if ( uriStartIndex > 1 ) - { - TPtrC tempStr( resultStr.Left( uriStartIndex ) ); - // remove possible quotation marks from displayname - TInt index = tempStr.Locate( KQuotationMark ); - if ( KErrNotFound != index ) + if ( KErrNotFound != uriStartIndex && KErrNotFound != uriEndIndex ) + { + if ( uriStartIndex < uriEndIndex ) { - // marks have to be removed - tempStr.Set( tempStr.Mid( ++index ) ); - if ( tempStr[tempStr.Length() - 1] == KQuotationMark ) - { - tempStr.Set( tempStr.Left( tempStr.Length() - 1 ) ); - } + // brackets found so modify descriptor and save the display info + + // check if there is anything before "<" if there is use + // it as displayname if match op fails. + if ( uriStartIndex > 1 ) + { + TPtrC tempStr( resultStr.Left( uriStartIndex ) ); + // remove possible quotation marks from displayname + TInt index = tempStr.Locate( KQuotationMark ); + if ( KErrNotFound != index ) + { + // marks have to be removed + tempStr.Set( tempStr.Mid( ++index ) ); + if ( tempStr[tempStr.Length() - 1] == KQuotationMark ) + { + tempStr.Set( tempStr.Left( tempStr.Length() - 1 ) ); + } + } + aResult = aDisplayname.Create( tempStr ); + } + } + else + { + // Start and end separators in wrong order: "xxxx>xxxx