ipsservices/ipssosplugin/src/ipsplgmsgkey.cpp
branchRCL_3
changeset 20 efd4f1afd43e
parent 0 8466d47a6819
child 24 d189ee25cf9d
equal deleted inserted replaced
18:6b8f3b30d0ec 20:efd4f1afd43e
    98                     leftEntry.iDetails.CompareC( rightEntry.iDetails );
    98                     leftEntry.iDetails.CompareC( rightEntry.iDetails );
    99                 break;
    99                 break;
   100                 }
   100                 }
   101             case EFSMailSortBySubject:
   101             case EFSMailSortBySubject:
   102                 {
   102                 {
   103                 // <cmail> due to changes in CompareSubject method
   103                 result = CompareSubjects( leftEntry.iDescription,
   104                 TRAP_IGNORE( result = CompareSubjectsL( 
   104                     rightEntry.iDescription );
   105                     leftEntry.iDescription, rightEntry.iDescription ) );
       
   106                 // </cmail>
       
   107                 break;
   105                 break;
   108                 }
   106                 }
   109             case EFSMailSortByPriority:
   107             case EFSMailSortByPriority:
   110                 // The values of TMsvPriority are defined so that the highest
   108                 // The values of TMsvPriority are defined so that the highest
   111                 // priority has the smallest value
   109                 // priority has the smallest value
   206 
   204 
   207 // ---------------------------------------------------------------------------
   205 // ---------------------------------------------------------------------------
   208 // Strips the subject prefixes before comparing the strings
   206 // Strips the subject prefixes before comparing the strings
   209 // ---------------------------------------------------------------------------
   207 // ---------------------------------------------------------------------------
   210 
   208 
   211 TInt TIpsPlgMsgKey::CompareSubjectsL( 
   209 TInt TIpsPlgMsgKey::CompareSubjects(
   212     const TDesC& aLeft, 
   210     const TDesC& aLeft, 
   213     const TDesC& aRight ) const
   211     const TDesC& aRight ) const
   214     {
   212     {
   215     FUNC_LOG;
   213     FUNC_LOG;
   216     TInt  result( KEqual );
   214     TInt  result( KEqual );
   217     TPtrC leftPtr( aLeft );
   215     const TInt leftOffset = FindSubjectStart( aLeft );
   218     TPtrC rightPtr( aRight );
   216     const TInt rightOffset = FindSubjectStart( aRight );
   219     TInt  leftOffset( FindSubjectStart( aLeft ) );
   217     TPtrC leftPtr( aLeft.Ptr() + leftOffset, aLeft.Length() - leftOffset );
   220     TInt  rightOffset( FindSubjectStart( aRight ) );
   218     TPtrC rightPtr( aRight.Ptr() + rightOffset, aRight.Length() - rightOffset );
   221     
   219  
   222     leftPtr.Set( 
   220     // for unifying with UI - remove all white spaces
   223         leftPtr.Ptr() + leftOffset, leftPtr.Length() - leftOffset );
   221     HBufC* croppedLeft = leftPtr.Alloc();
   224     rightPtr.Set( 
   222     HBufC* croppedRight = rightPtr.Alloc();
   225         rightPtr.Ptr() + rightOffset, rightPtr.Length() - rightOffset );
   223  
   226     
   224     // Comparison is done only when allocation succeeds
   227     // <cmail> for unifying with UI - remove all white spaces
   225     if ( croppedLeft && croppedRight )
   228     HBufC* croppedLeft = leftPtr.AllocLC();
   226         {
   229     TPtr croppedLeftPtr = croppedLeft->Des();
   227         TPtr croppedLeftPtr = croppedLeft->Des();
   230     HBufC* croppedRight = rightPtr.AllocLC();
   228         TPtr croppedRightPtr = croppedRight->Des();
   231     TPtr croppedRightPtr = croppedRight->Des();
   229  
   232         
   230         AknTextUtils::ReplaceCharacters( croppedLeftPtr, KCharsToReplace, ' ' );
   233     AknTextUtils::ReplaceCharacters( croppedLeftPtr, KCharsToReplace, ' ' );
   231         croppedLeftPtr.TrimAll();
   234     croppedLeftPtr.TrimAll();
   232         AknTextUtils::ReplaceCharacters( croppedRightPtr, KCharsToReplace, ' ' );
   235     AknTextUtils::ReplaceCharacters( croppedRightPtr, KCharsToReplace, ' ' );
   233         croppedRightPtr.TrimAll();
   236     croppedRightPtr.TrimAll();
   234  
   237     
   235         result = croppedLeftPtr.CompareC( croppedRightPtr );
   238     result = croppedLeftPtr.CompareC( croppedRightPtr );
   236         }
   239     
   237  
   240     CleanupStack::PopAndDestroy( croppedRight );
   238     delete croppedRight;
   241     CleanupStack::PopAndDestroy( croppedLeft );
   239     delete croppedLeft;
   242     // </cmail>
       
   243         
   240         
   244     return result;
   241     return result;
   245     }
   242     }
   246     
   243     
   247 // ---------------------------------------------------------------------------
   244 // ---------------------------------------------------------------------------