emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp
branchRCL_3
changeset 12 f5907b1a1053
parent 8 e1b6206813b4
child 13 0396474f30f5
equal deleted inserted replaced
8:e1b6206813b4 12:f5907b1a1053
    19 #include <f32file.h>
    19 #include <f32file.h>
    20 #include <s32file.h>
    20 #include <s32file.h>
    21 #include <e32cmn.h>
    21 #include <e32cmn.h>
    22 #include <utf.h>
    22 #include <utf.h>
    23 #include <StringLoader.h>
    23 #include <StringLoader.h>
       
    24 #include <AknsUtils.h>
       
    25 #include <AknsSkinInstance.h>
       
    26 #include <AknsConstants.h>
    24 
    27 
    25 #include <FreestyleEmailUi.rsg>
    28 #include <FreestyleEmailUi.rsg>
    26 #include <finditemengine.h>
    29 #include <finditemengine.h>
    27 #include "FreestyleMessageHeaderHTML.h"
    30 #include "FreestyleMessageHeaderHTML.h"
    28 #include "FreestyleEmailUiUtilities.h"
    31 #include "FreestyleEmailUiUtilities.h"
    67 _LIT8( KHTMLImgTagId, "<image id=\"" );
    70 _LIT8( KHTMLImgTagId, "<image id=\"" );
    68 _LIT8( KHTMLImgTagSrcBefore, "\" border=\"0\" src=\"" );
    71 _LIT8( KHTMLImgTagSrcBefore, "\" border=\"0\" src=\"" );
    69 _LIT8( KHTMLImgTagSrcAfter, "\">" );
    72 _LIT8( KHTMLImgTagSrcAfter, "\">" );
    70 
    73 
    71 _LIT8( KMetaHeader, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" );
    74 _LIT8( KMetaHeader, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" );
       
    75 
       
    76 _LIT8( KDisplayImagesLeftToRight,
       
    77         "<script language=\"javascript\">var g_autoLoadImages = %d;</script><table style=\"display: none;\" id=\"displayImagesTable\" width=\"%dpx\"><tr><td align=\"left\">%S</td><td align=\"right\"><input type=\"submit\" class=\"button\" value=\"%S\" onClick=\"displayImagesButtonPressed()\"/></td></tr></table>" );
       
    78 
       
    79 _LIT8( KDisplayImagesRightToLeft,
       
    80         "<script language=\"javascript\">var g_autoLoadImages = %d;</script><table style=\"display: none;\" id=\"displayImagesTable\" width=\"%dpx\"><tr><td align=\"left\"><input type=\"submit\" class=\"button\" value=\"%S\" onClick=\"displayImagesButtonPressed()\"/></td><td align=\"right\">%S</td></tr></table>" );
       
    81 
    72 const TInt KMaxEventLength( 256 );
    82 const TInt KMaxEventLength( 256 );
    73 const TInt KFreestyleMessageHeaderHTMLRightMarginInPx( 10 );
    83 const TInt KFreestyleMessageHeaderHTMLRightMarginInPx( 10 );
    74 const TInt KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth( 5 );
    84 const TInt KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth( 5 );
       
    85 
       
    86 // Define this to allow theme colorin for the header
       
    87 #undef __USE_THEME_COLOR_FOR_HEADER    
    75 
    88 
    76 EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage, 
    89 EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage, 
    77                                                                          RWriteStream& aWriteStream,
    90                                                                          RWriteStream& aWriteStream,
    78                                                                          TInt aVisibleWidth,
    91                                                                          TInt aVisibleWidth,
    79                                                                          TInt aScrollPosition,
    92                                                                          TInt aScrollPosition,
    80                                                                          TBidiText::TDirectionality aDirectionality
    93                                                                          const TBool aAutoLoadImages,
       
    94                                                                          const TBool aExpanded 
    81                                                                          )
    95                                                                          )
    82     {
    96     {
    83     CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aDirectionality);
    97     CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aAutoLoadImages, aExpanded);
    84     self->ConstructL();
    98     self->ConstructL();
    85     return self;
    99     return self;
    86     }
   100     }
    87 
   101 
    88 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
   102 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
    89                                                     RWriteStream& aWriteStream, 
   103                                                     RWriteStream& aWriteStream, 
    90                                                     TInt aVisibleWidth,
   104                                                     TInt aVisibleWidth,
    91                                                     TInt aScrollPosition,
   105                                                     TInt aScrollPosition,
    92                                                     TBidiText::TDirectionality aDirectionality)
   106                                                     const TBool aAutoLoadImages,
    93     {
   107                                                     const TBool aExpanded )
    94     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aDirectionality);
   108     {
       
   109     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aAutoLoadImages, aExpanded);
    95     CleanupStack::PushL( headerHtml );
   110     CleanupStack::PushL( headerHtml );
    96     headerHtml->ExportL();
   111     headerHtml->ExportL();
    97     CleanupStack::PopAndDestroy( headerHtml );
   112     CleanupStack::PopAndDestroy( headerHtml );
    98     }
   113     }
    99 
   114 
   100 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
   115 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
   101                                                     RFile& aFile, 
   116                                                     RFile& aFile, 
   102                                                     TInt aVisibleWidth,
   117                                                     TInt aVisibleWidth,
   103                                                     TInt aScrollPosition,
   118                                                     TInt aScrollPosition,
   104                                                     TBidiText::TDirectionality aDirectionality)
   119                                                     const TBool aAutoLoadImages,
       
   120                                                     const TBool aExpanded )
   105     {
   121     {
   106     RFileWriteStream fwstream;
   122     RFileWriteStream fwstream;
   107     fwstream.Attach( aFile, 0 );
   123     fwstream.Attach( aFile, 0 );
   108     CleanupClosePushL( fwstream );
   124     CleanupClosePushL( fwstream );
   109     
   125     
   110     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aDirectionality );
   126     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aAutoLoadImages, aExpanded );
   111     CleanupStack::PushL( headerHtml );
   127     CleanupStack::PushL( headerHtml );
   112     headerHtml->ExportL();
   128     headerHtml->ExportL();
   113     CleanupStack::PopAndDestroy( headerHtml );
   129     CleanupStack::PopAndDestroy( headerHtml );
   114     
   130     
   115     CleanupStack::PopAndDestroy( &fwstream );
   131     CleanupStack::PopAndDestroy( &fwstream );
   118 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
   134 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
   119                                                     RFs& aFs, 
   135                                                     RFs& aFs, 
   120                                                     const TPath& aFilePath, 
   136                                                     const TPath& aFilePath, 
   121                                                     TInt aVisibleWidth,
   137                                                     TInt aVisibleWidth,
   122                                                     TInt aScrollPosition,
   138                                                     TInt aScrollPosition,
   123                                                     TBidiText::TDirectionality aDirectionality)
   139                                                     const TBool aAutoLoadImages,
       
   140                                                     const TBool aExpanded )
   124     {
   141     {
   125     RFileWriteStream fwstream;
   142     RFileWriteStream fwstream;
   126     User::LeaveIfError( fwstream.Replace( aFs, aFilePath, EFileStreamText | EFileWrite) );
   143     User::LeaveIfError( fwstream.Replace( aFs, aFilePath, EFileStreamText | EFileWrite) );
   127     CleanupClosePushL( fwstream );
   144     CleanupClosePushL( fwstream );
   128     
   145     
   129     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aDirectionality);
   146     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aAutoLoadImages, aExpanded);
   130     CleanupStack::PushL( headerHtml );
   147     CleanupStack::PushL( headerHtml );
   131     headerHtml->ExportL();
   148     headerHtml->ExportL();
   132     CleanupStack::PopAndDestroy( headerHtml );
   149     CleanupStack::PopAndDestroy( headerHtml );
   133 
   150 
   134     CleanupStack::PopAndDestroy( &fwstream );    
   151     CleanupStack::PopAndDestroy( &fwstream );    
   149 
   166 
   150 CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage,  
   167 CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage,  
   151                                                           RWriteStream& aWriteStream,
   168                                                           RWriteStream& aWriteStream,
   152                                                           TInt aVisibleWidth,
   169                                                           TInt aVisibleWidth,
   153                                                           TInt aScrollPosition,
   170                                                           TInt aScrollPosition,
   154                                                           TBidiText::TDirectionality aDirectionality )
   171                                                           const TBool aAutoLoadImages,
       
   172                                                           const TBool aExpanded )
   155     : iMailMessage( aMailMessage ),
   173     : iMailMessage( aMailMessage ),
   156     iWriteStream( aWriteStream ),
   174     iWriteStream( aWriteStream ),
   157     iVisibleWidth( aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx ),
   175     iVisibleWidth( aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx ),
   158     iScrollPosition(aScrollPosition),
   176     iScrollPosition( aScrollPosition ),
   159     iDirectionality( aDirectionality ),
   177     iAutoLoadImages( aAutoLoadImages ),
   160     iMirrorLayout( EFalse )
   178     iMirrorLayout( AknLayoutUtils::LayoutMirrored() ),
       
   179     iExpanded( aExpanded  )
   161     {
   180     {
   162     }
   181     }
   163 
   182 
   164 void CFreestyleMessageHeaderHTML::ConstructL()
   183 void CFreestyleMessageHeaderHTML::ConstructL()
   165     {
   184     {
   166     iMailMessage.AttachmentListL( iAttachments );
   185     iMailMessage.AttachmentListL( iAttachments );
   167     if ( AknLayoutUtils::LayoutMirrored() )
       
   168         {
       
   169         iMirrorLayout = ETrue;
       
   170         }
       
   171     }
   186     }
   172 
   187 
   173 void CFreestyleMessageHeaderHTML::HTMLStartL() const
   188 void CFreestyleMessageHeaderHTML::HTMLStartL() const
   174     {
   189     {
   175     iWriteStream.WriteL(_L8("<html"));
   190     iWriteStream.WriteL(_L8("<html"));
   233     ExportBccL();
   248     ExportBccL();
   234     ExportSentTimeL();
   249     ExportSentTimeL();
   235     ExportSubjectL();
   250     ExportSubjectL();
   236     EndHeaderTableL();
   251     EndHeaderTableL();
   237     ExportAttachmentsL();
   252     ExportAttachmentsL();
       
   253     ExportDisplayImagesTableL();
   238     HTMLBodyEndL();
   254     HTMLBodyEndL();
       
   255     }
       
   256 
       
   257 void CFreestyleMessageHeaderHTML::ExportDisplayImagesTableL() const
       
   258     {
       
   259     if (!iAutoLoadImages)
       
   260         {
       
   261         _LIT8(KDescription, "");
       
   262         _LIT8(KButton, "Display images");
       
   263         HBufC8* description = KDescription().AllocLC(); //HeadingTextLC(R_FREESTYLE_EMAIL_UI_IMAGES_ARE_NOT_DISPLAYED);
       
   264         HBufC8* button = KButton().AllocLC(); //HeadingTextLC(R_FREESTYLE_EMAIL_UI_DISPLAY_IMAGES);
       
   265         HBufC8* formatBuffer = NULL;
       
   266         if (iMirrorLayout)
       
   267             {
       
   268             formatBuffer = HBufC8::NewLC(KDisplayImagesRightToLeft().Length() + description->Length() + button->Length() + 8);
       
   269             formatBuffer->Des().Format(
       
   270                     KDisplayImagesRightToLeft(),
       
   271                     iAutoLoadImages,
       
   272                     iVisibleWidth,
       
   273                     button,
       
   274                     description);
       
   275             }
       
   276         else
       
   277             {
       
   278             formatBuffer = HBufC8::NewLC(KDisplayImagesLeftToRight().Length() + description->Length() + button->Length() + 8);
       
   279             formatBuffer->Des().Format(
       
   280                     KDisplayImagesLeftToRight(),
       
   281                     iAutoLoadImages,
       
   282                     iVisibleWidth,
       
   283                     description,
       
   284                     button);
       
   285             }
       
   286         iWriteStream.WriteL(*formatBuffer);
       
   287         CleanupStack::PopAndDestroy(3); // description, button, formatBuffer
       
   288         iWriteStream.CommitL();
       
   289         }
   239     }
   290     }
   240 
   291 
   241 void CFreestyleMessageHeaderHTML::HTMLBodyStartL() const
   292 void CFreestyleMessageHeaderHTML::HTMLBodyStartL() const
   242     {
   293     {
   243     TBuf8<KFreestyleMessageHeaderHTMLRightMarginInPx> scrollPos;
   294     TBuf8<KFreestyleMessageHeaderHTMLRightMarginInPx> scrollPos;
   244     scrollPos.AppendNum(iScrollPosition);
   295     scrollPos.AppendNum(iScrollPosition);
   245     iWriteStream.WriteL(_L8("<body onLoad = init("));
   296     iWriteStream.WriteL(_L8("<body onLoad = \"init("));
   246     iWriteStream.WriteL(scrollPos);
   297     iWriteStream.WriteL(scrollPos);
   247     iWriteStream.WriteL(_L8(")>\n"));
   298     iWriteStream.WriteL(_L8(")\">\n"));
   248     iWriteStream.CommitL();
   299     iWriteStream.CommitL();
   249     }
   300     }
   250 
   301 
   251 void CFreestyleMessageHeaderHTML::ExportInitialTableL() const
   302 void CFreestyleMessageHeaderHTML::ExportInitialTableL() const
   252     {
   303     {
   253     // set the width, using the visible screen width
   304     // set the width, using the visible screen width
   254     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
   305     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
   255     tableWidth.AppendNum( iVisibleWidth );
   306     tableWidth.AppendNum( iVisibleWidth );
   256     iWriteStream.WriteL(_L8("<table id=\"table_initial\" border=\"0\" width=\""));
   307     
   257     iWriteStream.WriteL( tableWidth );
   308     if (iExpanded)
   258     iWriteStream.WriteL( _L8("px\">\n"));
   309         {
       
   310         iWriteStream.WriteL(_L8("<table id=\"table_initial\" border=\"0\" width=\""));
       
   311         iWriteStream.WriteL( tableWidth );
       
   312         iWriteStream.WriteL( _L8("px\" style=\"display: none\">\n"));    
       
   313         }
       
   314     else
       
   315         {
       
   316         iWriteStream.WriteL(_L8("<table id=\"table_initial\" border=\"0\" width=\""));
       
   317         iWriteStream.WriteL( tableWidth );
       
   318         iWriteStream.WriteL( _L8("px\">\n"));    
       
   319         }
   259     
   320     
   260 
   321 
   261     // start first row: table with the sent info and the '+' icon
   322     // start first row: table with the sent info and the '+' icon
   262     iWriteStream.WriteL(_L8("<tr><td><table id=\"table_sent_and_plus\" border=\"0\" width=\""));
   323     iWriteStream.WriteL(_L8("<tr><td><table id=\"table_sent_and_plus\" border=\"0\" width=\""));
   263     iWriteStream.WriteL( tableWidth );
   324     iWriteStream.WriteL( tableWidth );
   305         }
   366         }
   306     else
   367     else
   307         {
   368         {
   308         iWriteStream.WriteL(_L8(" align=\"left\""));
   369         iWriteStream.WriteL(_L8(" align=\"left\""));
   309         }
   370         }
   310     iWriteStream.WriteL(_L8(" style=\"padding: 0px 10px 0px 0px;\"><image id=\"detail_img\" border=\"0\" src=\"plus.gif\" onClick=\"expandHeader()\" ></td>\n"));
   371     iWriteStream.WriteL(_L8(" style=\"padding: 0px 10px 0px 0px;\"><image width=\"55\" height=\"36\" id=\"detail_img\" border=\"0\" src=\"plus.gif\" onClick=\"expandHeader(true)\" ></td>\n"));
   311 
   372 
   312     
   373     
   313     // finish first row
   374     // finish first row
   314     iWriteStream.WriteL(_L8("</tr>\n"));  
   375     iWriteStream.WriteL(_L8("</tr>\n"));  
   315     iWriteStream.WriteL(_L8("</table></td></tr>\n"));
   376     iWriteStream.WriteL(_L8("</table></td></tr>\n"));
   787         // start attachments table
   848         // start attachments table
   788         iWriteStream.WriteL( _L8("<table id=\"") ); 
   849         iWriteStream.WriteL( _L8("<table id=\"") ); 
   789         iWriteStream.WriteL( KAttachmentTableName );
   850         iWriteStream.WriteL( KAttachmentTableName );
   790         iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\">\n") );  // width is set at 100% intentionally
   851         iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\">\n") );  // width is set at 100% intentionally
   791         
   852         
       
   853         // add attachment icon
   792         // start row
   854         // start row
   793         iWriteStream.WriteL( _L8("<tr>\n") );
   855         iWriteStream.WriteL( _L8("<tr>\n") );
   794           
       
   795         // add attachment icon
       
   796         iWriteStream.WriteL( _L8("<td width=\"1\" valign=\"top\"") );
   856         iWriteStream.WriteL( _L8("<td width=\"1\" valign=\"top\"") );
   797         if ( !iMirrorLayout )
   857         iWriteStream.WriteL(_L8(" align=\"left\""));
   798             {
   858 
   799             iWriteStream.WriteL(_L8(" align=\"left\""));
       
   800             }
       
   801         else
       
   802             {
       
   803             iWriteStream.WriteL(_L8(" align=\"right\""));
       
   804             }
       
   805         iWriteStream.WriteL( _L8("><image src=\"") );
   859         iWriteStream.WriteL( _L8("><image src=\"") );
   806         
   860         
   807         iWriteStream.WriteL( KAttachementIconGeneral );
   861         iWriteStream.WriteL( KAttachementIconGeneral );
   808         iWriteStream.WriteL( _L8("\" ></td>\n") );
   862         iWriteStream.WriteL( _L8("\" ></td>\n") );
   809         
       
   810         // start table of attachments as a table within a cell
   863         // start table of attachments as a table within a cell
   811         iWriteStream.WriteL( _L8("<td>\n") );
   864         iWriteStream.WriteL( _L8("<td>\n") );
   812         iWriteStream.WriteL(_L8("<table id=\"table_attachments_list\" border=\"0\" width=\"100%\">\n"));
   865         iWriteStream.WriteL(_L8("<table id=\"table_attachments_list\" border=\"0\" width=\"100%\">\n"));
       
   866 
   813         for (TInt i=0; i < attachmentsCount; i++)
   867         for (TInt i=0; i < attachmentsCount; i++)
   814             {
   868             {
   815             AddAttachmentL( *iAttachments[i] );
   869             AddAttachmentL( *iAttachments[i] );
   816             }
   870             }
   817 
   871 
   924       // round up
   978       // round up
   925       ++sizeInKB;
   979       ++sizeInKB;
   926       }
   980       }
   927     
   981     
   928     TBuf8<32> sizeText;
   982     TBuf8<32> sizeText;
       
   983     
       
   984     // Add right to left marker as "(" and ")" are messing up the html language markers
       
   985     // and &rlm is only added in mirror layout 
       
   986     if( iMirrorLayout )  
       
   987         {
       
   988     sizeText.Append( KSpace8 );
       
   989     sizeText.Append( _L8( "&rlm;" ) );
       
   990         }
       
   991     
   929     sizeText.Append( KSpace8 );
   992     sizeText.Append( KSpace8 );
   930     sizeText.Append( _L8("(") );
   993     sizeText.Append( _L8("(") );
   931     sizeText.AppendNum( sizeInKB );
   994     sizeText.AppendNum( sizeInKB );
   932     sizeText.Append( KSpace8 );
   995     sizeText.Append( KSpace8 );
   933     sizeText.Append( KAttachmentSizeUnit );
   996     sizeText.Append( KAttachmentSizeUnit );
   934     sizeText.Append( _L8(")") );
   997     sizeText.Append( _L8(")") );
       
   998     
       
   999     if( iMirrorLayout )
       
  1000         {
       
  1001     sizeText.Append( KSpace8 );
       
  1002     sizeText.Append( _L8( "&rlm;" ) );
       
  1003         }
       
  1004     
   935     iWriteStream.WriteL( sizeText );
  1005     iWriteStream.WriteL( sizeText );
   936 
  1006 
   937     EndHyperlinkL();
  1007     EndHyperlinkL();
   938 
  1008 
   939     iWriteStream.WriteL( _L8("</td></tr>\n") );
  1009     iWriteStream.WriteL( _L8("</td></tr>\n") );
   985     }
  1055     }
   986 
  1056 
   987 void CFreestyleMessageHeaderHTML::StartHeaderTableL( const TDesC8& aTableId ) const
  1057 void CFreestyleMessageHeaderHTML::StartHeaderTableL( const TDesC8& aTableId ) const
   988     {
  1058     {
   989     iWriteStream.WriteL( _L8("<table id=\"") );
  1059     iWriteStream.WriteL( _L8("<table id=\"") );
   990     iWriteStream.WriteL( aTableId );
  1060     iWriteStream.WriteL( aTableId );    
   991     
  1061     if (iExpanded)
   992     // use style="display:none" so that full header table is hidden initially
  1062         {
   993     iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\" style=\"display: none\">\n") );
  1063         iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\">\n") );    
   994     
  1064         }
       
  1065     else
       
  1066         {
       
  1067         iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\" style=\"display: none\">\n") );    
       
  1068         }   
   995     
  1069     
   996     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
  1070     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
   997     tableWidth.AppendNum( iVisibleWidth );
  1071     tableWidth.AppendNum( iVisibleWidth );
   998 
  1072 
   999     // Add "hide details" image as its own table with its own width
  1073     // Add "hide details" image as its own table with its own width
  1010         }
  1084         }
  1011     else
  1085     else
  1012         {
  1086         {
  1013         iWriteStream.WriteL(_L8(" align=\"left\""));
  1087         iWriteStream.WriteL(_L8(" align=\"left\""));
  1014         }
  1088         }
  1015     iWriteStream.WriteL( _L8(" style=\"padding: 0px 10px 0px 0px;\"><image id=\"hideDetails_img\" border=\"0\" src=\"minus.gif\" onClick=\"collapseHeader()\"></td>\n"));
  1089     iWriteStream.WriteL( _L8(" style=\"padding: 0px 10px 0px 0px;\"><image width=\"55\" height=\"36\" id=\"hideDetails_img\" border=\"0\" src=\"minus.gif\" onClick=\"collapseHeader(true)\"></td>\n"));
  1016 
  1090 
  1017     iWriteStream.WriteL( _L8("</tr>\n"));
  1091     iWriteStream.WriteL( _L8("</tr>\n"));
  1018     iWriteStream.WriteL( _L8("</table></td></tr>\n"));
  1092     iWriteStream.WriteL( _L8("</table></td></tr>\n"));
  1019     iWriteStream.CommitL();
  1093     iWriteStream.CommitL();
  1020     }
  1094     }
  1123     iWriteStream.WriteL( _L8("<style type=\"text/css\">\n") );
  1197     iWriteStream.WriteL( _L8("<style type=\"text/css\">\n") );
  1124     
  1198     
  1125     // define a div class "header", specifying the background color
  1199     // define a div class "header", specifying the background color
  1126     // for the email header part
  1200     // for the email header part
  1127     
  1201     
  1128     // In future, query for which background color to use
  1202 #ifdef __USE_THEME_COLOR_FOR_HEADER    
  1129     iWriteStream.WriteL( _L8("body { background-color: lightblue; }\n") );
  1203     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1204     TRgb textColor;
       
  1205     TRgb bgColor;
       
  1206     // Should use EAknsCIFsTextColorsCG3 if background is white
       
  1207      if ( AknsUtils::GetCachedColor( skin, textColor,
       
  1208                  KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG81 ) != KErrNone ||
       
  1209           AknsUtils::GetCachedColor( skin, bgColor,
       
  1210                  KAknsIIDQsnOtherColors, EAknsCIQsnOtherColorsCG22 ) != KErrNone )
       
  1211          {
       
  1212          iWriteStream.WriteL( _L8("body { color: black; background-color: lightblue; }\n") );
       
  1213          }
       
  1214      else 
       
  1215          {
       
  1216          // In future, query for which background color to use
       
  1217          _LIT8( KBodyWithColor, "body { color: #%06x; background-color: #%06x; }\n" );
       
  1218          HBufC8* formatBuffer = HBufC8::NewLC(KBodyWithColor().Length() + 16);
       
  1219          formatBuffer->Des().Format(KBodyWithColor(), textColor.Internal() & 0xFFFFFF, bgColor.Internal() & 0xFFFFFF);
       
  1220          iWriteStream.WriteL( *formatBuffer );
       
  1221          CleanupStack::PopAndDestroy(); // formatBuffer
       
  1222          }
       
  1223 #else
       
  1224      iWriteStream.WriteL( _L8("body { color: black; background-color: lightblue; }\n") );
       
  1225 #endif // __USE_THEME_COLOR_FOR_HEADER    
  1130     
  1226     
  1131     // set font size to 75% of the default size
  1227     // set font size to 75% of the default size
  1132     // because, at the default size, the header text is too big relative to the text in the email body
  1228     // because, at the default size, the header text is too big relative to the text in the email body
  1133     // Note: since the text in the body is too small at "normal" level, 
  1229     // Note: since the text in the body is too small at "normal" level, 
  1134     // we have the text size level in the browser set to "Larger" which is 20% larger than the specified size
  1230     // we have the text size level in the browser set to "Larger" which is 20% larger than the specified size
  1135     // the "larger" size affects all text which includes the header.
  1231     // the "larger" size affects all text which includes the header.
  1136     iWriteStream.WriteL( _L8("td { font-family:arial,sans-serif ; font-size:75% }\n"));
  1232     iWriteStream.WriteL( _L8("td { font-family:arial,sans-serif ; font-size:75% }\n"));
  1137     
  1233     iWriteStream.WriteL( _L8(".button { background: url('btn_middle.png') repeat-x top left; border: 1px solid #546284; height: 32px; font-size:19px; font-weight: bold; color: #344a6c; font-family:arial,sans-serif; }\n") );
  1138     iWriteStream.WriteL( _L8("</style>\n") );
  1234     iWriteStream.WriteL( _L8("</style>\n") );
  1139     iWriteStream.CommitL();
  1235     iWriteStream.CommitL();
  1140     }
  1236     }
  1141 
  1237 
  1142 void CFreestyleMessageHeaderHTML::StartDivL() const
  1238 void CFreestyleMessageHeaderHTML::StartDivL() const