diff -r e7aa27f58ae1 -r e1b6206813b4 emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp --- a/emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp Tue Feb 02 00:02:40 2010 +0200 +++ b/emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp Fri Feb 19 22:37:30 2010 +0200 @@ -23,7 +23,7 @@ #include #include - +#include #include "FreestyleMessageHeaderHTML.h" #include "FreestyleEmailUiUtilities.h" #include "ncsconstants.h" @@ -156,22 +156,31 @@ iWriteStream( aWriteStream ), iVisibleWidth( aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx ), iScrollPosition(aScrollPosition), - iDirectionality( aDirectionality ) + iDirectionality( aDirectionality ), + iMirrorLayout( EFalse ) { } void CFreestyleMessageHeaderHTML::ConstructL() { iMailMessage.AttachmentListL( iAttachments ); + if ( AknLayoutUtils::LayoutMirrored() ) + { + iMirrorLayout = ETrue; + } } void CFreestyleMessageHeaderHTML::HTMLStartL() const { iWriteStream.WriteL(_L8("\n")); iWriteStream.CommitL(); } @@ -258,7 +267,8 @@ // add Sent time and date iWriteStream.WriteL(_L8("\n")); iWriteStream.WriteL(_L8("")); - HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() ); - CleanupStack::PushL( subject8 ); - iWriteStream.WriteL( *subject8 ); - CleanupStack::PopAndDestroy( subject8 ); + HBufC* subject = iMailMessage.GetSubject().Alloc(); + /* + * Writes the subject to iWriteStream and also + * takes care of the urls and marks them as hotspots + */ + WriteSubjectL(*subject); + iWriteStream.WriteL(_L8("")); // Write icons (if necessary). @@ -347,6 +360,90 @@ iWriteStream.CommitL(); } +// ----------------------------------------------------------------------------- +// CFreestyleMessageHeaderHTML::WriteSubjectL +// Writes the subject to iWriteStream and also +// takes care of the urls and marks them as hotspots +// ----------------------------------------------------------------------------- +// +void CFreestyleMessageHeaderHTML::WriteSubjectL(TDesC& aText ) const + { + /* + * Add these to searchcases to make it also search + * for emailaddress and phonenumber : + * CFindItemEngine::EFindItemSearchMailAddressBin | + * CFindItemEngine::EFindItemSearchPhoneNumberBin | + */ + // Search for urls + TInt searchCases = CFindItemEngine::EFindItemSearchURLBin; + + CFindItemEngine* itemEngine = + CFindItemEngine::NewL ( aText, + ( CFindItemEngine::TFindItemSearchCase ) searchCases ); + CleanupStack::PushL (itemEngine ); + + const CArrayFixFlat + * foundItems = itemEngine->ItemArray ( ); + + TInt index = 0; + // For each found item + for (TInt i=0; iCount ( ); ++i ) + { + // iItemType, iStartPos, iLength + const CFindItemEngine::SFoundItem& item = foundItems->At (i ); + HBufC* valueBuf = aText.Mid (item.iStartPos, item.iLength ).AllocL ( ); + CleanupStack::PushL (valueBuf ); + // We write the normal text to iWriteStream before and between the links in the header subject field + if(item.iStartPos > 0) + { + TInt itemstart = item.iStartPos; + HBufC* normalText = aText.Mid(index, itemstart-index).Alloc(); + CleanupStack::PushL( normalText ); + HBufC8* normalText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *normalText ); + CleanupStack::PushL( normalText8 ); + iWriteStream.WriteL( *normalText8 ); + CleanupStack::PopAndDestroy( 2 ); //normalText8m, normalText + } + switch (item.iItemType ) + { + /* To make header subjectfield to recognise also phonenumber and emailadress just + * add CFindItemEngine::EFindItemSearchMailAddressBin & + * CFindItemEngine::EFindItemSearchPhoneNumberBin cases here. + */ + case CFindItemEngine::EFindItemSearchURLBin: + { + HBufC8* url8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *valueBuf ); + FreestyleMessageHeaderURLFactory::CreateEmailSubjectUrlL(*valueBuf); + CleanupStack::PushL( url8 ); + StartHyperlinkL(*url8); + iWriteStream.WriteL(*url8); + EndHyperlinkL(); + CleanupStack::PopAndDestroy( url8 ); + + break; + } + default: + { + break; + } + } + index = item.iStartPos+item.iLength; + CleanupStack::PopAndDestroy (valueBuf ); + } + //Write the rest of the subject to subject field if we are not + //at the end of the subject already, or if there wasn't any + //url items write the whole subject field here + if(index < aText.Length() ) + { + HBufC* normalText = aText.Mid(index, aText.Length()-index).Alloc(); + CleanupStack::PushL( normalText ); + HBufC8* normalText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *normalText ); + CleanupStack::PushL( normalText8 ); + iWriteStream.WriteL( *normalText8 ); + CleanupStack::PopAndDestroy( 2 ); //normalText8m, normalText + } + CleanupStack::PopAndDestroy (itemEngine ); + } HBufC8* CFreestyleMessageHeaderHTML::HTMLHeaderFollowUpIconLC( TBool aShowText ) const { @@ -567,11 +664,12 @@ // subject text iWriteStream.WriteL( _L8("") ); iWriteStream.WriteL( _L8("") ); - - HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() ); - CleanupStack::PushL( subject8 ); - iWriteStream.WriteL( *subject8 ); - CleanupStack::PopAndDestroy( subject8 ); + HBufC* subject = iMailMessage.GetSubject().Alloc(); + /* + * Writes the subject to iWriteStream and also + * takes care of the urls and marks them as hotspots + */ + WriteSubjectL(*subject); iWriteStream.WriteL( _L8("") ); iWriteStream.WriteL( _L8("\n") ); @@ -696,13 +794,13 @@ // add attachment icon iWriteStream.WriteL( _L8(" 0 ) + // ENLN-7ZVBES + // Display name not shown in From:, instead, email address is shown + if ( (aEmailAddress.GetDisplayName().Length() > 0) && aEmailAddressType != FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom ) { displayName8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aEmailAddress.GetDisplayName() ); } @@ -904,7 +1004,7 @@ iWriteStream.WriteL( _L8("\n")); iWriteStream.WriteL( _L8("