emailuis/emailui/src/ncsutility.cpp
branchRCL_3
changeset 10 f5907b1a1053
parent 8 e1b6206813b4
child 11 0396474f30f5
equal deleted inserted replaced
8:e1b6206813b4 10:f5907b1a1053
    34 #include <eikimage.h>
    34 #include <eikimage.h>
    35 #include <fbs.h>
    35 #include <fbs.h>
    36 #include <flogger.h>
    36 #include <flogger.h>
    37 #include <aknenv.h>	// CAknEnv
    37 #include <aknenv.h>	// CAknEnv
    38 
    38 
    39 #include "cfsmailbox.h"
    39 #include "CFSMailBox.h"
    40 #include "cfsmailclient.h"
    40 #include "CFSMailClient.h"
    41 #include "cfsmailaddress.h"
    41 #include "CFSMailAddress.h"
    42 
    42 
    43 #include <aknlayoutscalable_apps.cdl.h>
    43 #include <aknlayoutscalable_apps.cdl.h>
    44 #include <layoutmetadata.cdl.h>
    44 #include <layoutmetadata.cdl.h>
    45 #include <AknLayoutFont.h>
    45 #include <AknLayoutFont.h>
    46 
    46 
   298 // -----------------------------------------------------------------------------
   298 // -----------------------------------------------------------------------------
   299 //
   299 //
   300 HBufC* NcsUtility::FormatSubjectLineL( 
   300 HBufC* NcsUtility::FormatSubjectLineL( 
   301         const TDesC& aNewSubjectLine, const TDesC& aPrefix )
   301         const TDesC& aNewSubjectLine, const TDesC& aPrefix )
   302 	{
   302 	{
   303     FUNC_LOG;
   303 	FUNC_LOG;
   304 
   304 	   
   305 	HBufC* formattedSubjectLine = aNewSubjectLine.AllocLC();
   305 	    HBufC* formattedSubjectLine = aNewSubjectLine.AllocLC();
   306 	HBufC* prefix = aPrefix.AllocLC();
   306 	    HBufC* prefix = aPrefix.AllocLC();
   307 
   307 	    TPtr formattedSubjectLinePtr = formattedSubjectLine->Des();
   308 	TPtr formattedSubjectLinePtr = formattedSubjectLine->Des();
   308 	    TPtr prefixPtr = prefix->Des();
   309 	TPtr prefixPtr = prefix->Des();
   309 	    prefixPtr.Trim();
   310 	prefixPtr.Trim();
   310 	    
   311 
   311 	    TInt subjectLineLength = formattedSubjectLinePtr.Length();
   312 	TInt subjectLineLength = formattedSubjectLinePtr.Length();
   312 	    TInt length = subjectLineLength;
   313 	TInt index = 0;
   313 	    TInt prefixLength = prefixPtr.Length();
   314 	TInt length = subjectLineLength;
   314 	    HBufC* fwdPrefix = StringLoader::LoadLC( R_NCS_ENGINE_EMAIL_FORWARD_PREFIX );
   315 	TInt prefixLength = prefixPtr.Length();
   315 	    TPtr fwdPrt = fwdPrefix->Des();
   316 
   316 	    TInt fwdLength = fwdPrt.Length();
   317 	do
   317 	    fwdPrt.Trim();
   318 		{
   318 	    
   319 		formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length );
   319 	      for(TInt index = formattedSubjectLinePtr.FindC( prefixPtr ); index != KErrNotFound ; index = formattedSubjectLinePtr.FindC( prefixPtr ))
   320 		index = formattedSubjectLinePtr.FindC( prefixPtr );
   320 	        {
   321 		length = formattedSubjectLinePtr.Length() - index - prefixLength;
   321 	            formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length );
   322 		}
   322 	            length = formattedSubjectLinePtr.Length() - index - prefixLength;
   323 	while( index != KErrNotFound );
   323 	        }
   324 
   324 	       formattedSubjectLinePtr.Trim();
   325 	formattedSubjectLinePtr.Trim();
   325 	       
   326 
   326 	       for(TInt index = formattedSubjectLinePtr.FindC( fwdPrt) ; index != KErrNotFound  ; index = formattedSubjectLinePtr.FindC( fwdPrt ))
   327 	HBufC* finalSubject = HBufC::NewL( 
   327 	          {
   328 	        formattedSubjectLinePtr.Length() + prefixPtr.Length() + 
   328 	               formattedSubjectLinePtr = formattedSubjectLinePtr.RightTPtr( length );
   329 	        KSpace().Length() );
   329 	               length = formattedSubjectLinePtr.Length() - index - fwdLength;
   330 	TPtr ptr = finalSubject->Des();
   330 	          }
   331 	if ( AknLayoutUtils::LayoutMirrored() )
   331 
   332 		{
   332 	       formattedSubjectLinePtr.Trim();
   333 		ptr.Append( formattedSubjectLinePtr );
   333 	    
   334 		ptr.Append( KSpace );
   334 	    
   335 		ptr.Append( prefixPtr );		
   335 	    HBufC* finalSubject = HBufC::NewL( formattedSubjectLinePtr.Length() + prefixPtr.Length() + KSpace().Length()  );
   336 		}
   336 	    TPtr ptr = finalSubject->Des();
   337 	else
   337 	    if ( AknLayoutUtils::LayoutMirrored() )
   338 		{
   338 	        {
   339 		ptr.Append( prefixPtr );
   339 	        ptr.Append( formattedSubjectLinePtr );
   340 		ptr.Append( KSpace );
   340 	        ptr.Append( KSpace );
   341 		ptr.Append( formattedSubjectLinePtr );
   341 	        ptr.Append( prefixPtr );        
   342 		}
   342 	        
   343 
   343 	        }
   344 	CleanupStack::PopAndDestroy( prefix );
   344 	    else
   345 	CleanupStack::PopAndDestroy( formattedSubjectLine );
   345 	        {
   346 
   346 	        ptr.Append( prefixPtr );
   347 	return finalSubject;
   347 	        ptr.Append( KSpace );
       
   348 	        ptr.Append( formattedSubjectLinePtr );
       
   349 	    
       
   350 	        }
       
   351 	    CleanupStack::PopAndDestroy( fwdPrefix );
       
   352 	    CleanupStack::PopAndDestroy( prefix );
       
   353 	    CleanupStack::PopAndDestroy( formattedSubjectLine );
       
   354 
       
   355 	    return finalSubject;
   348 	}
   356 	}
   349 
   357 
   350 // -----------------------------------------------------------------------------
   358 // -----------------------------------------------------------------------------
   351 // NcsUtility::ConvertAddressArrayL()
   359 // NcsUtility::ConvertAddressArrayL()
   352 //
   360 //