emailuis/emailui/src/FreestyleMessageHeaderHTML.cpp
changeset 2 5253a20d2a1e
parent 1 12c456ceeff2
child 3 a4d6f1ea0416
equal deleted inserted replaced
1:12c456ceeff2 2:5253a20d2a1e
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of the License "Symbian Foundation License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
     8 *
     8 *
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    30 
    30 
    31 
    31 
    32 
    32 
    33 _LIT8( KShowDetailIconFileName, "plus.gif");
    33 _LIT8( KShowDetailIconFileName, "plus.gif");
    34 _LIT8( KAttachementIconGeneral, "attachment.gif");
    34 _LIT8( KAttachementIconGeneral, "attachment.gif");
       
    35 _LIT8( KFollowUpIconFileName, "follow_up.png");
       
    36 _LIT8( KFollowUpCompleteIconFileName, "follow_up_complete.png");
       
    37 _LIT8( KPriorityHighIconFileName, "todo_high_add.png");
       
    38 _LIT8( KPriorityLowIconFileName, "todo_low_add.png");
    35 
    39 
    36 _LIT8( KHeaderTableName, "header_table");
    40 _LIT8( KHeaderTableName, "header_table");
    37 _LIT8( KToTableName, "to_table");
    41 _LIT8( KToTableName, "to_table");
    38 _LIT8( KCcTableName, "cc_table");
    42 _LIT8( KCcTableName, "cc_table");
    39 _LIT8( KBccTableName, "bcc_table");
    43 _LIT8( KBccTableName, "bcc_table");
    50 _LIT8( KToImageName, "to_img");
    54 _LIT8( KToImageName, "to_img");
    51 _LIT8( KCcImageName, "cc_img");
    55 _LIT8( KCcImageName, "cc_img");
    52 _LIT8( KBccImageName, "bcc_img");
    56 _LIT8( KBccImageName, "bcc_img");
    53 _LIT8( KAttachmentImageName, "attachment_img");
    57 _LIT8( KAttachmentImageName, "attachment_img");
    54 _LIT8( KDetailImageName, "detail_img");
    58 _LIT8( KDetailImageName, "detail_img");
       
    59 _LIT8( KFollowUpImageName, "follow_up_img");
       
    60 _LIT8( KFollowUpCompleteImageName, "follow_up_complete_img");
       
    61 _LIT8( KPriorityHighImageName, "todo_high_add_img");
       
    62 _LIT8( KPriorityLowImageName, "todo_low_add_img");
    55 
    63 
    56 _LIT8( KAttachmentSizeUnit, "kb");
    64 _LIT8( KAttachmentSizeUnit, "kb");
    57 _LIT8( KSpace8, " ");
    65 _LIT8( KSpace8, " ");
       
    66 
       
    67 _LIT8( KHTMLImgTagId, "<image id=\"" );
       
    68 _LIT8( KHTMLImgTagSrcBefore, "\" border=\"0\" src=\"" );
       
    69 _LIT8( KHTMLImgTagSrcAfter, "\">" );
    58 
    70 
    59 _LIT8( KMetaHeader, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" );
    71 _LIT8( KMetaHeader, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n" );
    60 const TInt KMaxEventLength( 256 );
    72 const TInt KMaxEventLength( 256 );
    61 const TInt KFreestyleMessageHeaderHTMLRightMarginInPx( 10 );
    73 const TInt KFreestyleMessageHeaderHTMLRightMarginInPx( 10 );
    62 const TInt KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth( 5 );
    74 const TInt KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth( 5 );
    63 
    75 
    64 EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage, TInt aVisibleWidth   )
    76 EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage, 
    65     {
    77                                                                          RWriteStream& aWriteStream,
    66     CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage, aVisibleWidth  );
    78                                                                          TInt aVisibleWidth,
       
    79                                                                          TInt aScrollPosition,
       
    80                                                                          TBidiText::TDirectionality aDirectionality
       
    81                                                                          )
       
    82     {
       
    83     CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aDirectionality);
    67     self->ConstructL();
    84     self->ConstructL();
    68     return self;
    85     return self;
    69     }
    86     }
    70 
    87 
    71 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RWriteStream& aWriteStream, TInt aVisibleWidth   )
    88 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
    72     {
    89                                                     RWriteStream& aWriteStream, 
    73     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
    90                                                     TInt aVisibleWidth,
       
    91                                                     TInt aScrollPosition,
       
    92                                                     TBidiText::TDirectionality aDirectionality)
       
    93     {
       
    94     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aDirectionality);
    74     CleanupStack::PushL( headerHtml );
    95     CleanupStack::PushL( headerHtml );
    75     headerHtml->ExportL( aWriteStream );
    96     headerHtml->ExportL();
    76     CleanupStack::PopAndDestroy( headerHtml );
    97     CleanupStack::PopAndDestroy( headerHtml );
    77     }
    98     }
    78 
    99 
    79 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RFile& aFile, TInt aVisibleWidth   )
   100 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
    80     {
   101                                                     RFile& aFile, 
    81     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
   102                                                     TInt aVisibleWidth,
    82     CleanupStack::PushL( headerHtml );
   103                                                     TInt aScrollPosition,
    83     headerHtml->ExportL( aFile );
   104                                                     TBidiText::TDirectionality aDirectionality)
    84     CleanupStack::PopAndDestroy( headerHtml );
       
    85     }
       
    86 
       
    87 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, RFs& aFs, const TPath& aFilePath, TInt aVisibleWidth  )
       
    88     {
       
    89     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aVisibleWidth   );
       
    90     CleanupStack::PushL( headerHtml );
       
    91     headerHtml->ExportL( aFs, aFilePath );
       
    92     CleanupStack::PopAndDestroy( headerHtml );
       
    93     }
       
    94 
       
    95 CFreestyleMessageHeaderHTML::~CFreestyleMessageHeaderHTML()
       
    96     {
       
    97     iAttachments.ResetAndDestroy();
       
    98     }
       
    99 
       
   100 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( RWriteStream& aWriteStream ) const
       
   101     {
       
   102     HTMLStartL( aWriteStream );
       
   103     ExportHTMLHeaderL( aWriteStream );
       
   104     ExportHTMLBodyL( aWriteStream );
       
   105     HTMLEndL( aWriteStream );
       
   106     }
       
   107 
       
   108 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( RFile& aFile ) const
       
   109     {
   105     {
   110     RFileWriteStream fwstream;
   106     RFileWriteStream fwstream;
   111     fwstream.Attach( aFile, 0 );
   107     fwstream.Attach( aFile, 0 );
   112     CleanupClosePushL( fwstream );
   108     CleanupClosePushL( fwstream );
   113     ExportL( fwstream );
   109     
       
   110     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aDirectionality );
       
   111     CleanupStack::PushL( headerHtml );
       
   112     headerHtml->ExportL();
       
   113     CleanupStack::PopAndDestroy( headerHtml );
       
   114     
   114     CleanupStack::PopAndDestroy( &fwstream );
   115     CleanupStack::PopAndDestroy( &fwstream );
   115     }
   116     }
   116 
   117 
   117 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( RFs& aFs, const TPath& aFilePath) const
   118 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, 
       
   119                                                     RFs& aFs, 
       
   120                                                     const TPath& aFilePath, 
       
   121                                                     TInt aVisibleWidth,
       
   122                                                     TInt aScrollPosition,
       
   123                                                     TBidiText::TDirectionality aDirectionality)
   118     {
   124     {
   119     RFileWriteStream fwstream;
   125     RFileWriteStream fwstream;
   120     User::LeaveIfError( fwstream.Replace( aFs, aFilePath, EFileStreamText | EFileWrite) );
   126     User::LeaveIfError( fwstream.Replace( aFs, aFilePath, EFileStreamText | EFileWrite) );
   121     CleanupClosePushL( fwstream );
   127     CleanupClosePushL( fwstream );
   122     ExportL( fwstream );
   128     
   123     CleanupStack::PopAndDestroy( &fwstream );
   129     CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aDirectionality);
   124     }
   130     CleanupStack::PushL( headerHtml );
   125 
   131     headerHtml->ExportL();
   126 CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage,  TInt aVisibleWidth  )
   132     CleanupStack::PopAndDestroy( headerHtml );
   127     : iMailMessage( aMailMessage )
   133 
   128     {
   134     CleanupStack::PopAndDestroy( &fwstream );    
   129     iVisibleWidth = aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx;
   135     }
   130   	}
   136 
   131   	
   137 CFreestyleMessageHeaderHTML::~CFreestyleMessageHeaderHTML()
       
   138     {
       
   139     iAttachments.ResetAndDestroy();
       
   140     }
       
   141 
       
   142 EXPORT_C void CFreestyleMessageHeaderHTML::ExportL() const
       
   143     {
       
   144     HTMLStartL();
       
   145     ExportHTMLHeaderL();
       
   146     ExportHTMLBodyL();
       
   147     HTMLEndL();
       
   148     }
       
   149 
       
   150 CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage,  
       
   151                                                           RWriteStream& aWriteStream,
       
   152                                                           TInt aVisibleWidth,
       
   153                                                           TInt aScrollPosition,
       
   154                                                           TBidiText::TDirectionality aDirectionality )
       
   155     : iMailMessage( aMailMessage ),
       
   156     iWriteStream( aWriteStream ),
       
   157     iVisibleWidth( aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx ),
       
   158     iScrollPosition(aScrollPosition),
       
   159     iDirectionality( aDirectionality )
       
   160     {
       
   161     }
       
   162 
   132 void CFreestyleMessageHeaderHTML::ConstructL()
   163 void CFreestyleMessageHeaderHTML::ConstructL()
   133     {
   164     {
   134     iMailMessage.AttachmentListL( iAttachments );
   165     iMailMessage.AttachmentListL( iAttachments );
   135     }
   166     }
   136 
   167 
   137 void CFreestyleMessageHeaderHTML::HTMLStartL( RWriteStream& aWriteStream ) const
   168 void CFreestyleMessageHeaderHTML::HTMLStartL() const
   138     {
   169     {
   139     aWriteStream.WriteL(_L8("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"));
   170     iWriteStream.WriteL(_L8("<html"));
   140     aWriteStream.CommitL();
   171     if ( iDirectionality == TBidiText::ERightToLeft )
   141     }
   172         {
   142 
   173         iWriteStream.WriteL(_L8(" dir=\"rtl\""));
   143 void CFreestyleMessageHeaderHTML::HTMLEndL( RWriteStream& aWriteStream ) const
   174         }    
   144     {
   175     iWriteStream.WriteL(_L8(" xmlns=\"http://www.w3.org/1999/xhtml\">\n"));
   145     aWriteStream.WriteL(_L8("</html>\n"));
   176     iWriteStream.CommitL();
   146     aWriteStream.CommitL();
   177     }
   147     }
   178 
   148 
   179 void CFreestyleMessageHeaderHTML::HTMLEndL() const
   149 void CFreestyleMessageHeaderHTML::ExportHTMLHeaderL( RWriteStream& aWriteStream ) const
   180     {
   150     {
   181     iWriteStream.WriteL(_L8("</html>\n"));
   151     HTMLHeaderStartL( aWriteStream );
   182     iWriteStream.CommitL();
   152     HTMLMetaL( aWriteStream );
   183     }
   153     aWriteStream.WriteL(_L8("<title>Email Header</title>\n"));
   184 
   154     AddJavascriptL( aWriteStream );
   185 void CFreestyleMessageHeaderHTML::ExportHTMLHeaderL() const
   155     AddStyleSheetL( aWriteStream );
   186     {
   156     HTMLHeaderEndL( aWriteStream );
   187     HTMLHeaderStartL();
   157     }
   188     HTMLMetaL();
   158 
   189     iWriteStream.WriteL( _L8("<title>Email Header</title>\n") );
   159 void CFreestyleMessageHeaderHTML::HTMLHeaderStartL( RWriteStream& aWriteStream ) const
   190     AddJavascriptL();
   160     {
   191     AddStyleSheetL();
   161     aWriteStream.WriteL(_L8("<head>"));
   192     HTMLHeaderEndL();
   162     aWriteStream.CommitL();
   193     }
   163     }
   194 
   164 
   195 void CFreestyleMessageHeaderHTML::HTMLHeaderStartL() const
   165 void CFreestyleMessageHeaderHTML::HTMLMetaL( RWriteStream& aWriteStream ) const
   196     {
       
   197     iWriteStream.WriteL(_L8("<head>"));
       
   198     iWriteStream.CommitL();
       
   199     }
       
   200 
       
   201 void CFreestyleMessageHeaderHTML::HTMLMetaL() const
   166     {
   202     {
   167     // Html file representing email header fields, is always constructed locally
   203     // Html file representing email header fields, is always constructed locally
   168     // in the phone, and it is always of charset UTF-8 irrespective of what
   204     // in the phone, and it is always of charset UTF-8 irrespective of what
   169     // the email html-format body is
   205     // the email html-format body is
   170     aWriteStream.WriteL( KMetaHeader );
   206     iWriteStream.WriteL( KMetaHeader );
   171     aWriteStream.CommitL();
   207     iWriteStream.CommitL();
   172     }
   208     }
   173 
   209 
   174 void CFreestyleMessageHeaderHTML::HTMLHeaderEndL( RWriteStream& aWriteStream ) const
   210 void CFreestyleMessageHeaderHTML::HTMLHeaderEndL() const
   175     {
   211     {
   176     aWriteStream.WriteL(_L8("</head>\n"));
   212     iWriteStream.WriteL(_L8("</head>\n"));
   177     aWriteStream.CommitL();
   213     iWriteStream.CommitL();
   178     }
   214     }
   179 
   215 
   180 void CFreestyleMessageHeaderHTML::ExportHTMLBodyL( RWriteStream& aWriteStream ) const
   216 void CFreestyleMessageHeaderHTML::ExportHTMLBodyL() const
   181     {
   217     {
   182     HTMLBodyStartL( aWriteStream );
   218     HTMLBodyStartL();
   183     ExportInitialTableL( aWriteStream );
   219     ExportInitialTableL();
   184     StartHeaderTableL( aWriteStream, KHeaderTableName );
   220     StartHeaderTableL( KHeaderTableName );
   185     ExportFromL( aWriteStream );
   221     ExportFromL();
   186     ExportToL( aWriteStream );
   222     ExportToL();
   187     ExportCcL( aWriteStream );
   223     ExportCcL();
   188     ExportBccL( aWriteStream );
   224     ExportBccL();
   189     ExportSentTimeL( aWriteStream );
   225     ExportSentTimeL();
   190     ExportSubjectL( aWriteStream );
   226     ExportSubjectL();
   191     EndHeaderTableL( aWriteStream );
   227     EndHeaderTableL();
   192     ExportAttachmentsL( aWriteStream );
   228     ExportAttachmentsL();
   193     HTMLBodyEndL( aWriteStream );
   229     HTMLBodyEndL();
   194     }
   230     }
   195 
   231 
   196 void CFreestyleMessageHeaderHTML::HTMLBodyStartL( RWriteStream& aWriteStream ) const
   232 void CFreestyleMessageHeaderHTML::HTMLBodyStartL() const
   197     {
   233     {
   198     aWriteStream.WriteL(_L8("<body>\n"));
   234     TBuf8<KFreestyleMessageHeaderHTMLRightMarginInPx> scrollPos;
   199     aWriteStream.CommitL();
   235     scrollPos.AppendNum(iScrollPosition);
   200     }
   236     iWriteStream.WriteL(_L8("<body onLoad = init("));
   201 void CFreestyleMessageHeaderHTML::ExportInitialTableL( RWriteStream& aWriteStream ) const
   237     iWriteStream.WriteL(scrollPos);
   202     {
   238     iWriteStream.WriteL(_L8(")>\n"));
   203 
   239     iWriteStream.CommitL();
       
   240     }
       
   241 
       
   242 void CFreestyleMessageHeaderHTML::ExportInitialTableL() const
       
   243     {
   204     // set the width, using the visible screen width
   244     // set the width, using the visible screen width
   205     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
   245     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
   206     tableWidth.AppendNum( iVisibleWidth );
   246     tableWidth.AppendNum( iVisibleWidth );
   207     aWriteStream.WriteL(_L8("<table id=\"table_initial\" border=\"0\" width=\""));
   247     iWriteStream.WriteL(_L8("<table id=\"table_initial\" border=\"0\" width=\""));
   208     aWriteStream.WriteL( tableWidth );
   248     iWriteStream.WriteL( tableWidth );
   209     aWriteStream.WriteL( _L8("px\">\n"));
   249     iWriteStream.WriteL( _L8("px\">\n"));
   210     
   250     
   211 
   251 
   212     // start first row: table with the sent info and the '+' icon
   252     // start first row: table with the sent info and the '+' icon
   213     aWriteStream.WriteL(_L8("<tr><td><table id=\"table_sent_and_plus\" border=\"0\" width=\""));
   253     iWriteStream.WriteL(_L8("<tr><td><table id=\"table_sent_and_plus\" border=\"0\" width=\""));
   214     aWriteStream.WriteL( tableWidth );
   254     iWriteStream.WriteL( tableWidth );
   215     aWriteStream.WriteL( _L8("px\">\n"));
   255     iWriteStream.WriteL( _L8("px\">\n"));
   216     
   256     
   217     aWriteStream.WriteL(_L8("<tr>\n"));
   257     iWriteStream.WriteL(_L8("<tr>\n"));
   218     
   258     
   219     // add Sent time and date
   259     // add Sent time and date
   220     aWriteStream.WriteL(_L8("<td id=\"sent_initial\" align=\"left\" valign=\"bottom\">"));
   260     iWriteStream.WriteL(_L8("<td id=\"sent_initial\""));
       
   261     if ( iDirectionality == TBidiText::ELeftToRight )
       
   262         {
       
   263         iWriteStream.WriteL(_L8(" align=\"left\""));
       
   264         }
       
   265     else
       
   266         {
       
   267         iWriteStream.WriteL(_L8(" align=\"right\""));
       
   268         }
       
   269     iWriteStream.WriteL(_L8(" valign=\"bottom\">"));
   221     
   270     
   222     HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage );
   271     HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage );
   223     HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &iMailMessage );
   272     HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &iMailMessage );
   224 
   273 
   225     TInt len = dateText->Length() + KSentLineDateAndTimeSeparatorText().Length() + timeText->Length();
   274     TInt len = dateText->Length() + KSentLineDateAndTimeSeparatorText().Length() + timeText->Length();
   228     sentTimeTextPtr.Append( *dateText );
   277     sentTimeTextPtr.Append( *dateText );
   229     sentTimeTextPtr.Append( KSentLineDateAndTimeSeparatorText );
   278     sentTimeTextPtr.Append( KSentLineDateAndTimeSeparatorText );
   230     sentTimeTextPtr.Append( *timeText );
   279     sentTimeTextPtr.Append( *timeText );
   231     HBufC8* sentTimeText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( sentTimeTextPtr );
   280     HBufC8* sentTimeText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( sentTimeTextPtr );
   232     CleanupStack::PushL( sentTimeText8 );
   281     CleanupStack::PushL( sentTimeText8 );
   233     aWriteStream.WriteL( *sentTimeText8 );
   282     iWriteStream.WriteL( *sentTimeText8 );
   234     CleanupStack::PopAndDestroy( sentTimeText8 );
   283     CleanupStack::PopAndDestroy( sentTimeText8 );
   235     CleanupStack::PopAndDestroy( sentTimeText );
   284     CleanupStack::PopAndDestroy( sentTimeText );
   236     CleanupStack::PopAndDestroy( timeText );
   285     CleanupStack::PopAndDestroy( timeText );
   237     CleanupStack::PopAndDestroy( dateText );
   286     CleanupStack::PopAndDestroy( dateText );
   238     
   287     
   239     aWriteStream.WriteL(_L8("</td>\n"));
   288     iWriteStream.WriteL(_L8("</td>\n"));
   240     
   289     
   241     // add "show details" image on the same line as Sent time and date
   290     // add "show details" image on the same line as Sent time and date
   242     aWriteStream.WriteL(_L8("<td width=\"1\" valign=\"top\" align=\"right\" style=\"padding: 0px 10px 0px 0px;\"><image id=\"detail_img\" border=\"0\" src=\"plus.gif\" onClick=\"expandHeader()\" ></td>\n"));
   291     iWriteStream.WriteL(_L8("<td width=\"1\" valign=\"top\""));
   243         
   292     if ( iDirectionality == TBidiText::ELeftToRight )
       
   293         {
       
   294         iWriteStream.WriteL(_L8(" align=\"right\""));
       
   295         }
       
   296     else
       
   297         {
       
   298         iWriteStream.WriteL(_L8(" align=\"left\""));
       
   299         }
       
   300     iWriteStream.WriteL(_L8(" style=\"padding: 0px 10px 0px 0px;\"><image id=\"detail_img\" border=\"0\" src=\"plus.gif\" onClick=\"expandHeader()\" ></td>\n"));
       
   301 
       
   302     
   244     // finish first row
   303     // finish first row
   245     aWriteStream.WriteL(_L8("</tr>\n"));  
   304     iWriteStream.WriteL(_L8("</tr>\n"));  
   246     aWriteStream.WriteL(_L8("</table></td></tr>\n"));
   305     iWriteStream.WriteL(_L8("</table></td></tr>\n"));
   247 
   306 
   248     //=============================
   307     //=============================
   249     // start second row which contains subject
   308     // start second row which contains subject
   250     aWriteStream.WriteL(_L8("<tr>\n"));
   309     iWriteStream.WriteL(_L8("<tr>\n"));
   251     aWriteStream.WriteL(_L8("<td id=\"subject_initial\" align=\"left\"><b>"));
   310     iWriteStream.WriteL(_L8("<td id=\"subject_initial\""));
       
   311     if ( iDirectionality == TBidiText::ELeftToRight )
       
   312         {
       
   313         iWriteStream.WriteL(_L8(" align=\"left\""));
       
   314         }
       
   315     else
       
   316         {
       
   317         iWriteStream.WriteL(_L8(" align=\"right\""));
       
   318         }
       
   319     iWriteStream.WriteL(_L8("><b>"));
   252 
   320 
   253     HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() );
   321     HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() );
   254     CleanupStack::PushL( subject8 );
   322     CleanupStack::PushL( subject8 );
   255     aWriteStream.WriteL( *subject8 );
   323     iWriteStream.WriteL( *subject8 );
   256     CleanupStack::PopAndDestroy( subject8 );
   324     CleanupStack::PopAndDestroy( subject8 );
   257 
   325     iWriteStream.WriteL(_L8("</b>"));
   258     aWriteStream.WriteL(_L8("</b></td>\n"));
   326         
   259     aWriteStream.WriteL(_L8("</tr>\n"));  // finish subject row
   327     // Write icons (if necessary).
       
   328     HBufC8* followUp = HTMLHeaderFollowUpIconLC( EFalse );
       
   329     HBufC8* priority = HTMLHeaderPriorityIconLC( EFalse );
       
   330         
       
   331     if ( priority )
       
   332         {
       
   333         iWriteStream.WriteL( *priority );
       
   334         CleanupStack::PopAndDestroy( priority);
       
   335         }
       
   336     
       
   337     if ( followUp )
       
   338         {
       
   339         iWriteStream.WriteL( *followUp );
       
   340         CleanupStack::PopAndDestroy( followUp );
       
   341         }
       
   342     
       
   343     iWriteStream.WriteL(_L8("</td></tr>\n"));  // finish subject row
   260     
   344     
   261     // end table_initial
   345     // end table_initial
   262     aWriteStream.WriteL(_L8("</table>\n"));
   346     iWriteStream.WriteL(_L8("</table>\n"));
   263         
   347         
   264     aWriteStream.CommitL();
   348     iWriteStream.CommitL();
   265     }
   349     }
   266 void CFreestyleMessageHeaderHTML::HTMLBodyEndL( RWriteStream& aWriteStream ) const
   350 
   267     {
   351 HBufC8* CFreestyleMessageHeaderHTML::HTMLHeaderFollowUpIconLC( TBool aShowText ) const
   268     aWriteStream.WriteL(_L8("</body>\n"));
   352     {
   269     aWriteStream.CommitL();
   353     HBufC8* followUpText8( NULL );
   270     }
   354     HBufC8* followUpCompletedText8( NULL );
   271 
   355         
   272 void CFreestyleMessageHeaderHTML::ExportSubjectL( RWriteStream& aWriteStream ) const
   356     // Reserve space with worst case scenario in mind. 
   273     {
   357     TInt textLength( 0 );
   274     aWriteStream.WriteL( _L8("<tr id=\"") );
   358     if ( aShowText )
   275     aWriteStream.WriteL( KSubjectFieldName );
   359         {
   276     aWriteStream.WriteL( _L8("\">") );
   360         // Follow up completed.
   277 
   361         HBufC* followUpCompletedText = StringLoader::LoadLC( 
   278 
   362                 R_FREESTYLE_EMAIL_UI_VIEWER_COMPLETED );
   279     aWriteStream.WriteL( _L8("<td width=\"1\">") );
   363         followUpCompletedText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
   280     aWriteStream.WriteL( _L8("<b>") );
   364                 *followUpCompletedText );
       
   365         CleanupStack::PopAndDestroy( followUpCompletedText );
       
   366         CleanupStack::PushL( followUpCompletedText8 );
       
   367         
       
   368         // Follow up.
       
   369         HBufC* followUpText = StringLoader::LoadLC( 
       
   370                 R_FREESTYLE_EMAIL_UI_VIEWER_FOLLOWUP );
       
   371         followUpText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
       
   372                 *followUpText );
       
   373         CleanupStack::PopAndDestroy( followUpText );
       
   374         CleanupStack::PushL( followUpText8 );
       
   375     
       
   376         textLength += KHTMLImgTagId().Length() +
       
   377                       KFollowUpCompleteImageName().Length() +
       
   378                       KHTMLImgTagSrcBefore().Length() +
       
   379                       KFollowUpCompleteIconFileName().Length() +
       
   380                       KHTMLImgTagSrcAfter().Length() +
       
   381                       ( followUpText8->Length() >= followUpCompletedText8->Length() ?
       
   382                       followUpText8->Length() : followUpCompletedText8->Length() ); 
       
   383         }
       
   384     else
       
   385         {
       
   386         // Plain icon and no text.
       
   387         textLength += KHTMLImgTagId().Length() + 
       
   388                       KFollowUpCompleteImageName().Length() +
       
   389                       KHTMLImgTagSrcBefore().Length() +
       
   390                       KFollowUpCompleteIconFileName().Length() +
       
   391                       KHTMLImgTagSrcAfter().Length();
       
   392         }
       
   393 
       
   394     // Allocate space.
       
   395     HBufC8* iconText8 = HBufC8::NewLC( textLength );    
       
   396         
       
   397     // Generate HTML code
       
   398     TPtr8 iconPtr( iconText8->Des() );
       
   399         
       
   400     if ( iMailMessage.IsFlagSet( EFSMsgFlag_FollowUp ) )
       
   401         {
       
   402         iconPtr.Append( KHTMLImgTagId );
       
   403         iconPtr.Append( KFollowUpImageName );
       
   404         iconPtr.Append( KHTMLImgTagSrcBefore );
       
   405         iconPtr.Append( KFollowUpIconFileName );
       
   406         iconPtr.Append( KHTMLImgTagSrcAfter );
       
   407         if ( aShowText && followUpText8 )
       
   408             {
       
   409             iconPtr.Append( followUpText8->Des() );
       
   410             }
       
   411         }
       
   412     else if ( iMailMessage.IsFlagSet( EFSMsgFlag_FollowUpComplete ) )
       
   413         {
       
   414         iconPtr.Append( KHTMLImgTagId );
       
   415         iconPtr.Append( KFollowUpCompleteImageName );
       
   416         iconPtr.Append( KHTMLImgTagSrcBefore );
       
   417         iconPtr.Append( KFollowUpCompleteIconFileName );
       
   418         iconPtr.Append( KHTMLImgTagSrcAfter );
       
   419         if ( aShowText && followUpCompletedText8 )
       
   420             {
       
   421             iconPtr.Append( followUpCompletedText8->Des() );
       
   422             }
       
   423         }
       
   424     else
       
   425         {
       
   426         // No follow up flag set.
       
   427         CleanupStack::PopAndDestroy( iconText8 );
       
   428         iconText8 = NULL;
       
   429         }
       
   430 
       
   431     if ( aShowText )
       
   432         {
       
   433         if ( iconText8 )
       
   434             {
       
   435             CleanupStack::Pop( iconText8 );
       
   436             }
       
   437         CleanupStack::PopAndDestroy( followUpText8 );
       
   438         CleanupStack::PopAndDestroy( followUpCompletedText8 );
       
   439         if ( iconText8 )
       
   440             {
       
   441             CleanupStack::PushL( iconText8 );
       
   442             }
       
   443         }
       
   444     
       
   445     return iconText8;
       
   446     }
       
   447 
       
   448 HBufC8* CFreestyleMessageHeaderHTML::HTMLHeaderPriorityIconLC( TBool aShowText ) const
       
   449     {
       
   450     HBufC8* highPrioText8( NULL );
       
   451     HBufC8* lowPrioText8( NULL );
       
   452         
       
   453     // Reserve space with worst case scenario in mind. 
       
   454     TInt textLength( 0 );
       
   455     if ( aShowText )
       
   456         {
       
   457         // High priority.
       
   458         HBufC* highPrioText = StringLoader::LoadLC( 
       
   459                 R_FREESTYLE_EMAIL_UI_VIEWER_HIGH_PRIO );
       
   460         highPrioText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
       
   461                 *highPrioText );
       
   462         CleanupStack::PopAndDestroy( highPrioText );
       
   463         CleanupStack::PushL( highPrioText8 );
       
   464     
       
   465         // Low priority.
       
   466         HBufC* lowPrioText = StringLoader::LoadLC( 
       
   467                 R_FREESTYLE_EMAIL_UI_VIEWER_LOW_PRIO );
       
   468         lowPrioText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
       
   469                 *lowPrioText );
       
   470         CleanupStack::PopAndDestroy( lowPrioText );
       
   471         CleanupStack::PushL( lowPrioText8 );
       
   472             
       
   473         textLength += KHTMLImgTagId().Length() +
       
   474                       KPriorityHighImageName().Length() +
       
   475                       KHTMLImgTagSrcBefore().Length() +
       
   476                       KPriorityHighIconFileName().Length() +
       
   477                       KHTMLImgTagSrcAfter().Length() +
       
   478                       ( lowPrioText8->Length() >= highPrioText8->Length() ?
       
   479                       lowPrioText8->Length() : highPrioText8->Length() ); 
       
   480         }
       
   481     else
       
   482         {
       
   483         // Plain icon and no text.
       
   484         textLength += KHTMLImgTagId().Length() + 
       
   485                       KPriorityHighImageName().Length() +
       
   486                       KHTMLImgTagSrcBefore().Length() +
       
   487                       KPriorityHighIconFileName().Length() +
       
   488                       KHTMLImgTagSrcAfter().Length();
       
   489         }
       
   490 
       
   491     // Allocate space.
       
   492     HBufC8* iconText8 = HBufC8::NewLC( textLength );    
       
   493         
       
   494     // Generate HTML code
       
   495     TPtr8 iconPtr( iconText8->Des() );
       
   496         
       
   497     if ( iMailMessage.IsFlagSet( EFSMsgFlag_Low ) )
       
   498         {
       
   499         iconPtr.Append( KHTMLImgTagId );
       
   500         iconPtr.Append( KPriorityLowImageName );
       
   501         iconPtr.Append( KHTMLImgTagSrcBefore );
       
   502         iconPtr.Append( KPriorityLowIconFileName );
       
   503         iconPtr.Append( KHTMLImgTagSrcAfter );
       
   504         if ( aShowText && lowPrioText8 )
       
   505             {
       
   506             iconPtr.Append( lowPrioText8->Des() );
       
   507             }
       
   508         }
       
   509     else if ( iMailMessage.IsFlagSet( EFSMsgFlag_Important ) )
       
   510         {
       
   511         iconPtr.Append( KHTMLImgTagId );
       
   512         iconPtr.Append( KPriorityHighImageName );
       
   513         iconPtr.Append( KHTMLImgTagSrcBefore );
       
   514         iconPtr.Append( KPriorityHighIconFileName );
       
   515         iconPtr.Append( KHTMLImgTagSrcAfter );
       
   516         if ( aShowText && highPrioText8 )
       
   517             {
       
   518             iconPtr.Append( highPrioText8->Des() );
       
   519             }
       
   520         }
       
   521     else
       
   522         {
       
   523         // No priority flag set.
       
   524         CleanupStack::PopAndDestroy( iconText8 );
       
   525         iconText8 = NULL;
       
   526         }
       
   527 
       
   528     if ( aShowText )
       
   529         {
       
   530         if ( iconText8 )
       
   531             {
       
   532             CleanupStack::Pop( iconText8 );
       
   533             }
       
   534         CleanupStack::PopAndDestroy( lowPrioText8 );
       
   535         CleanupStack::PopAndDestroy( highPrioText8 );
       
   536         if ( iconText8 )
       
   537             {
       
   538             CleanupStack::PushL( iconText8 );
       
   539             }
       
   540         }
       
   541     
       
   542     return iconText8;
       
   543     }
       
   544 
       
   545 void CFreestyleMessageHeaderHTML::HTMLBodyEndL() const
       
   546     {
       
   547     iWriteStream.WriteL(_L8("</body>\n"));
       
   548     iWriteStream.CommitL();
       
   549     }
       
   550 
       
   551 void CFreestyleMessageHeaderHTML::ExportSubjectL() const
       
   552     {
       
   553     iWriteStream.WriteL( _L8("<tr id=\"") );
       
   554     iWriteStream.WriteL( KSubjectFieldName );
       
   555     iWriteStream.WriteL( _L8("\">") );
       
   556 
       
   557 
       
   558     iWriteStream.WriteL( _L8("<td width=\"1\">") );
       
   559     iWriteStream.WriteL( _L8("<b>") );
   281     HBufC8* subjectHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_SUBJECT );
   560     HBufC8* subjectHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_SUBJECT );
   282     aWriteStream.WriteL( *subjectHeadingText );
   561     iWriteStream.WriteL( *subjectHeadingText );
   283     CleanupStack::PopAndDestroy( subjectHeadingText );
   562     CleanupStack::PopAndDestroy( subjectHeadingText );
   284     aWriteStream.WriteL( _L8("</b>") );
   563     iWriteStream.WriteL( _L8("</b>") );
   285     aWriteStream.WriteL( _L8("</td>") );
   564     iWriteStream.WriteL( _L8("</td>") );
   286     aWriteStream.WriteL( _L8("</tr>\n") );
   565     iWriteStream.WriteL( _L8("</tr>\n") );
   287     
   566     
   288     // subject text
   567     // subject text
   289     aWriteStream.WriteL( _L8("<tr>") );
   568     iWriteStream.WriteL( _L8("<tr>") );
   290     aWriteStream.WriteL( _L8("<td>") );
   569     iWriteStream.WriteL( _L8("<td>") );
   291 
   570 
   292     HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() );
   571     HBufC8* subject8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iMailMessage.GetSubject() );
   293     CleanupStack::PushL( subject8 );
   572     CleanupStack::PushL( subject8 );
   294     aWriteStream.WriteL( *subject8 );
   573     iWriteStream.WriteL( *subject8 );
   295     CleanupStack::PopAndDestroy( subject8 );
   574     CleanupStack::PopAndDestroy( subject8 );
   296 
   575 
   297     aWriteStream.WriteL( _L8("</td>") );
   576     iWriteStream.WriteL( _L8("</td>") );
   298     aWriteStream.WriteL( _L8("</tr>\n") );
   577     iWriteStream.WriteL( _L8("</tr>\n") );
   299 
   578     // Write icons (if necessary).
   300     aWriteStream.CommitL();
   579     HBufC8* followUp = HTMLHeaderFollowUpIconLC( ETrue );
   301     }
   580     HBufC8* priority = HTMLHeaderPriorityIconLC( ETrue );
   302 
   581    
   303 void CFreestyleMessageHeaderHTML::ExportFromL( RWriteStream& aWriteStream ) const
   582     if ( priority )
       
   583        {
       
   584        iWriteStream.WriteL(_L8("<tr><td>"));
       
   585        iWriteStream.WriteL( *priority );
       
   586        iWriteStream.WriteL(_L8("</td></tr>"));
       
   587        CleanupStack::PopAndDestroy( priority);
       
   588        }
       
   589    
       
   590     if ( followUp )
       
   591        {
       
   592        iWriteStream.WriteL(_L8("<tr><td>"));
       
   593        iWriteStream.WriteL( *followUp );
       
   594        iWriteStream.WriteL(_L8("</td></tr>"));
       
   595        CleanupStack::PopAndDestroy( followUp );
       
   596        }
       
   597 
       
   598     iWriteStream.CommitL();
       
   599     }
       
   600 
       
   601 void CFreestyleMessageHeaderHTML::ExportFromL() const
   304     {
   602     {
   305     RPointerArray<CFSMailAddress> froms;
   603     RPointerArray<CFSMailAddress> froms;
   306     CleanupClosePushL( froms );
   604     CleanupClosePushL( froms );
   307     CFSMailAddress* from = iMailMessage.GetSender();  // ownership not transferred
   605     CFSMailAddress* from = iMailMessage.GetSender();  // ownership not transferred
   308     if ( from )
   606     if ( from )
   309         {
   607         {
   310         froms.AppendL( from );
   608         froms.AppendL( from );
   311         }
   609         }
   312     ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom, froms, 
   610     ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::EEmailAddressTypeFrom, froms, 
   313                            KFromFieldName, KFromTableName, R_FREESTYLE_EMAIL_UI_VIEWER_FROM );
   611                            KFromFieldName, KFromTableName, R_FREESTYLE_EMAIL_UI_VIEWER_FROM );
   314     CleanupStack::PopAndDestroy( &froms );
   612     CleanupStack::PopAndDestroy( &froms );
   315     }
   613     }
   316 
   614 
   317 void CFreestyleMessageHeaderHTML::ExportToL( RWriteStream& aWriteStream ) const
   615 void CFreestyleMessageHeaderHTML::ExportToL() const
   318     {
   616     {
   319     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetToRecipients();
   617     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetToRecipients();
   320     ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo, recipients,
   618     ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::EEmailAddressTypeTo, recipients,
   321                            KToFieldName, KToTableName, R_FREESTYLE_EMAIL_UI_VIEWER_TO );
   619                            KToFieldName, KToTableName, R_FREESTYLE_EMAIL_UI_VIEWER_TO );
   322     }
   620     }
   323 
   621 
   324 void CFreestyleMessageHeaderHTML::ExportCcL( RWriteStream& aWriteStream ) const
   622 void CFreestyleMessageHeaderHTML::ExportCcL() const
   325     {
   623     {
   326     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetCCRecipients();
   624     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetCCRecipients();
   327     ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc, recipients,
   625     ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::EEmailAddressTypeCc, recipients,
   328                            KCcFieldName, KCcTableName, R_FREESTYLE_EMAIL_UI_VIEWER_CC );
   626                            KCcFieldName, KCcTableName, R_FREESTYLE_EMAIL_UI_VIEWER_CC );
   329     }
   627     }
   330 
   628 
   331 void CFreestyleMessageHeaderHTML::ExportBccL( RWriteStream& aWriteStream ) const
   629 void CFreestyleMessageHeaderHTML::ExportBccL() const
   332     {
   630     {
   333     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetBCCRecipients();
   631     RPointerArray<CFSMailAddress>& recipients = iMailMessage.GetBCCRecipients();
   334     ExportEmailAddressesL( aWriteStream, FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc, recipients,
   632     ExportEmailAddressesL( FreestyleMessageHeaderURLFactory::EEmailAddressTypeBcc, recipients,
   335                            KBccFieldName, KBccTableName, R_FREESTYLE_EMAIL_UI_VIEWER_BCC );
   633                            KBccFieldName, KBccTableName, R_FREESTYLE_EMAIL_UI_VIEWER_BCC );
   336     }
   634     }
   337 
   635 
   338 void CFreestyleMessageHeaderHTML::ExportSentTimeL( RWriteStream& aWriteStream ) const
   636 void CFreestyleMessageHeaderHTML::ExportSentTimeL() const
   339     {
   637     {
   340 
   638 
   341     aWriteStream.WriteL( _L8("<tr id=\"") );
   639     iWriteStream.WriteL( _L8("<tr id=\"") );
   342     aWriteStream.WriteL( KSentFieldName );
   640     iWriteStream.WriteL( KSentFieldName );
   343     aWriteStream.WriteL( _L8("\">") );
   641     iWriteStream.WriteL( _L8("\">") );
   344 
   642 
   345 
   643 
   346     aWriteStream.WriteL( _L8("<td width=\"1\">") );
   644     iWriteStream.WriteL( _L8("<td width=\"1\">") );
   347     aWriteStream.WriteL( _L8("<b>") );
   645     iWriteStream.WriteL( _L8("<b>") );
   348     HBufC8* sentHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_SENT );
   646     HBufC8* sentHeadingText = HeadingTextLC( R_FREESTYLE_EMAIL_UI_VIEWER_SENT );
   349     aWriteStream.WriteL( *sentHeadingText );
   647     iWriteStream.WriteL( *sentHeadingText );
   350     CleanupStack::PopAndDestroy( sentHeadingText );
   648     CleanupStack::PopAndDestroy( sentHeadingText );
   351     aWriteStream.WriteL( _L8("</b>") );
   649     iWriteStream.WriteL( _L8("</b>") );
   352     aWriteStream.WriteL( _L8("</td>") );
   650     iWriteStream.WriteL( _L8("</td>") );
   353     aWriteStream.WriteL( _L8("</tr>\n") );
   651     iWriteStream.WriteL( _L8("</tr>\n") );
   354 
   652 
   355     aWriteStream.WriteL( _L8("<tr>") );
   653     iWriteStream.WriteL( _L8("<tr>") );
   356     aWriteStream.WriteL( _L8("<td>") );
   654     iWriteStream.WriteL( _L8("<td>") );
   357 
   655 
   358     HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage );
   656     HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage );
   359     HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &iMailMessage );
   657     HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &iMailMessage );
   360 
   658 
   361     TInt len = dateText->Length() + KSentLineDateAndTimeSeparatorText().Length() + timeText->Length();
   659     TInt len = dateText->Length() + KSentLineDateAndTimeSeparatorText().Length() + timeText->Length();
   364     sentTimeTextPtr.Append( *dateText );
   662     sentTimeTextPtr.Append( *dateText );
   365     sentTimeTextPtr.Append( KSentLineDateAndTimeSeparatorText );
   663     sentTimeTextPtr.Append( KSentLineDateAndTimeSeparatorText );
   366     sentTimeTextPtr.Append( *timeText );
   664     sentTimeTextPtr.Append( *timeText );
   367     HBufC8* sentTimeText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( sentTimeTextPtr );
   665     HBufC8* sentTimeText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( sentTimeTextPtr );
   368     CleanupStack::PushL( sentTimeText8 );
   666     CleanupStack::PushL( sentTimeText8 );
   369     aWriteStream.WriteL( *sentTimeText8 );
   667     iWriteStream.WriteL( *sentTimeText8 );
   370     CleanupStack::PopAndDestroy( sentTimeText8 );
   668     CleanupStack::PopAndDestroy( sentTimeText8 );
   371     CleanupStack::PopAndDestroy( sentTimeText );
   669     CleanupStack::PopAndDestroy( sentTimeText );
   372     CleanupStack::PopAndDestroy( timeText );
   670     CleanupStack::PopAndDestroy( timeText );
   373     CleanupStack::PopAndDestroy( dateText );
   671     CleanupStack::PopAndDestroy( dateText );
   374 
   672 
   375     aWriteStream.WriteL( _L8("</td>") );
   673     iWriteStream.WriteL( _L8("</td>") );
   376 
   674 
   377     aWriteStream.WriteL( _L8("</tr>\n") );
   675     iWriteStream.WriteL( _L8("</tr>\n") );
   378 
   676 
   379     aWriteStream.CommitL();
   677     iWriteStream.CommitL();
   380     }
   678     }
   381 
   679 
   382 void CFreestyleMessageHeaderHTML::ExportAttachmentsL( RWriteStream& aWriteStream ) const
   680 void CFreestyleMessageHeaderHTML::ExportAttachmentsL() const
   383     {
   681     {
   384 
   682     TInt attachmentsCount (iAttachments.Count());
   385     TInt attachmentsCount( iAttachments.Count() );
   683     if ( attachmentsCount)
   386     if ( attachmentsCount )
       
   387         {
   684         {
   388         // The attachments table consists of one row that contains 2 cells
   685         // The attachments table consists of one row that contains 2 cells
   389         // first cell contains the attachment icon
   686         // first cell contains the attachment icon
   390         // second cell contains a table which contains the attachments list
   687         // second cell contains a table which contains the attachments list
   391 
   688 
   392         // start attachments table
   689         // start attachments table
   393         aWriteStream.WriteL( _L8("<table id=\"") ); 
   690         iWriteStream.WriteL( _L8("<table id=\"") ); 
   394         aWriteStream.WriteL( KAttachmentTableName );
   691         iWriteStream.WriteL( KAttachmentTableName );
   395         aWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\">\n") );  // width is set at 100% intentionally
   692         iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\">\n") );  // width is set at 100% intentionally
   396         
   693         
   397         // start row
   694         // start row
   398         aWriteStream.WriteL( _L8("<tr>\n") );
   695         iWriteStream.WriteL( _L8("<tr>\n") );
   399           
   696           
   400         // add attachment icon
   697         // add attachment icon
   401         aWriteStream.WriteL( _L8("<td width=\"1\" valign=\"top\" align=\"right\"><image src=\"") );
   698         iWriteStream.WriteL( _L8("<td width=\"1\" valign=\"top\"") );
   402         aWriteStream.WriteL( KAttachementIconGeneral );
   699         if ( iDirectionality == TBidiText::ELeftToRight )
   403         aWriteStream.WriteL( _L8("\" ></td>\n") );
   700             {
       
   701             iWriteStream.WriteL(_L8(" align=\"right\""));
       
   702             }
       
   703         else
       
   704             {
       
   705             iWriteStream.WriteL(_L8(" align=\"left\""));
       
   706             }
       
   707         iWriteStream.WriteL( _L8("><image src=\"") );
       
   708         
       
   709         iWriteStream.WriteL( KAttachementIconGeneral );
       
   710         iWriteStream.WriteL( _L8("\" ></td>\n") );
   404         
   711         
   405         // start table of attachments as a table within a cell
   712         // start table of attachments as a table within a cell
   406         aWriteStream.WriteL( _L8("<td>\n") );
   713         iWriteStream.WriteL( _L8("<td>\n") );
   407         aWriteStream.WriteL(_L8("<table id=\"table_attachments_list\" border=\"0\" width=\"100%\">\n"));
   714         iWriteStream.WriteL(_L8("<table id=\"table_attachments_list\" border=\"0\" width=\"100%\">\n"));
   408         for (TInt i=0; i < attachmentsCount; i++)
   715         for (TInt i=0; i < attachmentsCount; i++)
   409             {
   716             {
   410             AddAttachmentL( aWriteStream, *iAttachments[i] );
   717             AddAttachmentL( *iAttachments[i] );
   411             }
   718             }
   412 
   719 
   413         aWriteStream.WriteL(_L8("</table>\n")); // end table_attachments_list
   720         iWriteStream.WriteL(_L8("</table>\n")); // end table_attachments_list
   414         aWriteStream.WriteL( _L8("</td>\n") );
   721         iWriteStream.WriteL( _L8("</td>\n") );
   415         
   722         
   416         aWriteStream.WriteL( _L8("</tr>\n") );
   723         iWriteStream.WriteL( _L8("</tr>\n") );
   417         aWriteStream.WriteL(_L8("</table>\n")); // end attachments table
   724         iWriteStream.WriteL(_L8("</table>\n")); // end attachments table
   418         }
   725         }
   419     }
   726     }
   420 
   727 
   421 void CFreestyleMessageHeaderHTML::ExportEmailAddressesL( RWriteStream& aWriteStream, 
   728 void CFreestyleMessageHeaderHTML::ExportEmailAddressesL(FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
   422                                                         FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType, 
       
   423                                                         const RPointerArray<CFSMailAddress>& aEmailAddresses,
   729                                                         const RPointerArray<CFSMailAddress>& aEmailAddresses,
   424                                                         const TDesC8& aRowId,
   730                                                         const TDesC8& aRowId,
   425                                                         const TDesC8& /*aTableId*/,
   731                                                         const TDesC8& /*aTableId*/,
   426                                                         TInt aHeaderTextResourceId ) const
   732                                                         TInt aHeaderTextResourceId ) const
   427     {
   733     {
   428     if ( aEmailAddresses.Count() )
   734     if ( aEmailAddresses.Count() )
   429         {
   735         {
   430         // begin table row
   736         // begin table row
   431         aWriteStream.WriteL( _L8("<tr id=\"")); 
   737         iWriteStream.WriteL( _L8("<tr id=\"")); 
   432         aWriteStream.WriteL( aRowId );
   738         iWriteStream.WriteL( aRowId );
   433         aWriteStream.WriteL( _L8("\">") );
   739         iWriteStream.WriteL( _L8("\">") );
   434         
   740         
   435         // heading text
   741         // heading text
   436         aWriteStream.WriteL( _L8("<td><b>"));
   742         iWriteStream.WriteL( _L8("<td><b>"));
   437         HBufC8* headingText = HeadingTextLC( aHeaderTextResourceId );
   743         HBufC8* headingText = HeadingTextLC( aHeaderTextResourceId );
   438         aWriteStream.WriteL( *headingText );
   744         iWriteStream.WriteL( *headingText );
   439         CleanupStack::PopAndDestroy( headingText );
   745         CleanupStack::PopAndDestroy( headingText );
   440         aWriteStream.WriteL( _L8("</b></td>"));
   746         iWriteStream.WriteL( _L8("</b></td>"));
   441         
   747         
   442         aWriteStream.WriteL( _L8("</tr>\n") );  // end table row      
   748         iWriteStream.WriteL( _L8("</tr>\n") );  // end table row      
   443         
   749         
   444         // add addresses, one address per row
   750         // add addresses, one address per row
   445         TInt count( aEmailAddresses.Count() );
   751         TInt count( aEmailAddresses.Count() );
   446         for (TInt i = 0; i < count; ++i )
   752         for (TInt i = 0; i < count; ++i )
   447             {
   753             {
   448             aWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") );
   754             iWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") );
   449             AddEmailAddressL (aWriteStream, aEmailAddressType, *aEmailAddresses[i] );
   755             AddEmailAddressL (aEmailAddressType, *aEmailAddresses[i] );
   450             aWriteStream.WriteL( _L8("</td></tr>\n") );
   756             iWriteStream.WriteL( _L8("</td></tr>\n") );
   451             }
   757             }
   452 
   758 
   453         aWriteStream.CommitL();
   759         iWriteStream.CommitL();
   454         }
   760         }
   455     }
   761     }
   456 
   762 
   457 void CFreestyleMessageHeaderHTML::AddEmailAddressL( RWriteStream& aWriteStream,
   763 void CFreestyleMessageHeaderHTML::AddEmailAddressL( FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType,
   458         FreestyleMessageHeaderURLFactory::TEmailAddressType aEmailAddressType,
   764                                                     const CFSMailAddress& aEmailAddress ) const
   459         const CFSMailAddress& aEmailAddress ) const
       
   460     {
   765     {
   461     CFreestyleMessageHeaderURL* emailUrl = FreestyleMessageHeaderURLFactory::CreateEmailAddressUrlL( aEmailAddressType, aEmailAddress );
   766     CFreestyleMessageHeaderURL* emailUrl = FreestyleMessageHeaderURLFactory::CreateEmailAddressUrlL( aEmailAddressType, aEmailAddress );
   462     CleanupStack::PushL( emailUrl );
   767     CleanupStack::PushL( emailUrl );
   463 
   768 
   464     HBufC* url = emailUrl->ExternalizeL();
   769     HBufC* url = emailUrl->ExternalizeL();
   465     CleanupStack::PushL( url );
   770     CleanupStack::PushL( url );
   466     HBufC8* url8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *url );
   771     HBufC8* url8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *url );
   467     CleanupStack::PushL( url8 );
   772     CleanupStack::PushL( url8 );
   468     StartHyperlinkL( aWriteStream, *url8 );
   773     StartHyperlinkL( *url8 );
   469     CleanupStack::PopAndDestroy( url8 );
   774     CleanupStack::PopAndDestroy( url8 );
   470     CleanupStack::PopAndDestroy( url );
   775     CleanupStack::PopAndDestroy( url );
   471 
   776 
   472     HBufC8* displayName8 = NULL;
   777     HBufC8* displayName8 = NULL;
   473     if ( aEmailAddress.GetDisplayName().Length() > 0 )
   778     if ( aEmailAddress.GetDisplayName().Length() > 0 )
   477     else
   782     else
   478         {
   783         {
   479         displayName8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aEmailAddress.GetEmailAddress() );
   784         displayName8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aEmailAddress.GetEmailAddress() );
   480         }
   785         }
   481     CleanupStack::PushL( displayName8 );
   786     CleanupStack::PushL( displayName8 );
   482     aWriteStream.WriteL( *displayName8 );
   787     iWriteStream.WriteL( *displayName8 );
   483     CleanupStack::PopAndDestroy( displayName8 );
   788     CleanupStack::PopAndDestroy( displayName8 );
   484 
   789 
   485     EndHyperlinkL( aWriteStream );
   790     EndHyperlinkL();
   486 
   791 
   487     CleanupStack::PopAndDestroy( emailUrl );
   792     CleanupStack::PopAndDestroy( emailUrl );
   488     }
   793     }
   489 
   794 
   490 void CFreestyleMessageHeaderHTML::AddAttachmentL( RWriteStream& aWriteStream, CFSMailMessagePart& aAttachment ) const
   795 void CFreestyleMessageHeaderHTML::AddAttachmentL( CFSMailMessagePart& aAttachment ) const
   491     {
   796     {
   492     aWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") ); // pad bottom to allow some space between the lines
   797     iWriteStream.WriteL( _L8("<tr><td style=\"padding: 0px 0px 7px 0px;\">") ); // pad bottom to allow some space between the lines
   493 
   798 
   494     TUint id = aAttachment.GetPartId().Id();
   799     TUint id = aAttachment.GetPartId().Id();
   495     TBuf<32> itemId;
   800     TBuf<32> itemId;
   496     itemId.AppendNum( id );
   801     itemId.AppendNum( id );
   497     CFreestyleMessageHeaderURL* attnUrl = FreestyleMessageHeaderURLFactory::CreateAttachmentUrlL( itemId );
   802     CFreestyleMessageHeaderURL* attnUrl = FreestyleMessageHeaderURLFactory::CreateAttachmentUrlL( itemId );
   498     CleanupStack::PushL( attnUrl );
   803     CleanupStack::PushL( attnUrl );
   499     HBufC* attnUrlText = attnUrl->ExternalizeL();
   804     HBufC* attnUrlText = attnUrl->ExternalizeL();
   500     CleanupStack::PushL( attnUrlText );
   805     CleanupStack::PushL( attnUrlText );
   501     HBufC8* attnUrlText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *attnUrlText );
   806     HBufC8* attnUrlText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *attnUrlText );
   502     CleanupStack::PushL( attnUrlText8 );
   807     CleanupStack::PushL( attnUrlText8 );
   503     StartHyperlinkL( aWriteStream, *attnUrlText8 );
   808     StartHyperlinkL( *attnUrlText8 );
   504     CleanupStack::PopAndDestroy( attnUrlText8 );
   809     CleanupStack::PopAndDestroy( attnUrlText8 );
   505     CleanupStack::PopAndDestroy( attnUrlText );
   810     CleanupStack::PopAndDestroy( attnUrlText );
   506     CleanupStack::PopAndDestroy( attnUrl );
   811     CleanupStack::PopAndDestroy( attnUrl );
   507 
   812 
   508     TDesC& attnName = aAttachment.AttachmentNameL();
   813     TDesC& attnName = aAttachment.AttachmentNameL();
   509     HBufC8* attnName8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( attnName );
   814     HBufC8* attnName8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( attnName );
   510     CleanupStack::PushL( attnName8 );
   815     CleanupStack::PushL( attnName8 );
   511     aWriteStream.WriteL( *attnName8 );
   816     iWriteStream.WriteL( *attnName8 );
   512     CleanupStack::PopAndDestroy( attnName8 );
   817     CleanupStack::PopAndDestroy( attnName8 );
   513 
   818 
   514     TUint size = aAttachment.ContentSize();
   819     TUint size = aAttachment.ContentSize();
   515     TUint sizeInKB = size / 1024;
   820     TUint sizeInKB = size / 1024;
   516     
   821     
   525     sizeText.Append( _L8("(") );
   830     sizeText.Append( _L8("(") );
   526     sizeText.AppendNum( sizeInKB );
   831     sizeText.AppendNum( sizeInKB );
   527     sizeText.Append( KSpace8 );
   832     sizeText.Append( KSpace8 );
   528     sizeText.Append( KAttachmentSizeUnit );
   833     sizeText.Append( KAttachmentSizeUnit );
   529     sizeText.Append( _L8(")") );
   834     sizeText.Append( _L8(")") );
   530     aWriteStream.WriteL( sizeText );
   835     iWriteStream.WriteL( sizeText );
   531 
   836 
   532     EndHyperlinkL( aWriteStream );
   837     EndHyperlinkL();
   533 
   838 
   534     aWriteStream.WriteL( _L8("</td></tr>\n") );
   839     iWriteStream.WriteL( _L8("</td></tr>\n") );
   535     aWriteStream.CommitL();
   840     iWriteStream.CommitL();
   536     }
   841     }
   537 
   842 
   538 
   843 
   539 void CFreestyleMessageHeaderHTML::StartHyperlinkL( RWriteStream& aWriteStream, const TDesC8& aUrl ) const
   844 void CFreestyleMessageHeaderHTML::StartHyperlinkL( const TDesC8& aUrl ) const
   540     {
   845     {
   541     aWriteStream.WriteL( _L8("<a href=\"") );
   846     iWriteStream.WriteL( _L8("<a href=\"") );
   542     aWriteStream.WriteL( aUrl );
   847     iWriteStream.WriteL( aUrl );
   543     aWriteStream.WriteL( _L8("\">"));
   848     iWriteStream.WriteL( _L8("\">"));
   544     aWriteStream.CommitL();
   849     iWriteStream.CommitL();
   545     }
   850     }
   546 
   851 
   547 void CFreestyleMessageHeaderHTML::EndHyperlinkL( RWriteStream& aWriteStream ) const
   852 void CFreestyleMessageHeaderHTML::EndHyperlinkL() const
   548     {
   853     {
   549     aWriteStream.WriteL( _L8("</a>") );
   854     iWriteStream.WriteL( _L8("</a>") );
   550     aWriteStream.CommitL();
   855     iWriteStream.CommitL();
   551     }
   856     }
   552 
   857 
   553 void CFreestyleMessageHeaderHTML::AddImageL( RWriteStream& aWriteStream, const TDesC8& aImageUrl ) const
   858 void CFreestyleMessageHeaderHTML::AddImageL( const TDesC8& aImageUrl ) const
   554     {
   859     {
   555     aWriteStream.WriteL( _L8("<image border=\"0\" src=\"") );
   860     iWriteStream.WriteL( _L8("<image border=\"0\" src=\"") );
   556     aWriteStream.WriteL( aImageUrl );
   861     iWriteStream.WriteL( aImageUrl );
   557     aWriteStream.WriteL( _L8("\">"));
   862     iWriteStream.WriteL( _L8("\">"));
   558     aWriteStream.CommitL();
   863     iWriteStream.CommitL();
   559     }
   864     }
   560 
   865 
   561 void CFreestyleMessageHeaderHTML::AddImageL( RWriteStream& aWriteStream,
   866 void CFreestyleMessageHeaderHTML::AddImageL( const TDesC8& aImageId,
   562         const TDesC8& aImageId,
   867                                              const TDesC8& aImageUrl,
   563         const TDesC8& aImageUrl,
   868                                              const TDesC8& aImageEvent ) const
   564         const TDesC8& aImageEvent ) const
   869     {
   565     {
   870     iWriteStream.WriteL( _L8("<image id=\"") );
   566     aWriteStream.WriteL( _L8("<image id=\"") );
   871     iWriteStream.WriteL( aImageId );
   567     aWriteStream.WriteL( aImageId );
   872     iWriteStream.WriteL( _L8("\" ") );
   568     aWriteStream.WriteL( _L8("\" ") );
   873     iWriteStream.WriteL( _L8("border=\"0\" src=\"") );
   569     aWriteStream.WriteL( _L8("border=\"0\" src=\"") );
   874     iWriteStream.WriteL( aImageUrl );
   570     aWriteStream.WriteL( aImageUrl );
   875     iWriteStream.WriteL( _L8("\" "));
   571     aWriteStream.WriteL( _L8("\" "));
   876     iWriteStream.WriteL( aImageEvent );
   572     aWriteStream.WriteL( aImageEvent );
   877     iWriteStream.WriteL( _L8(">"));
   573     aWriteStream.WriteL( _L8(">"));
   878     iWriteStream.CommitL();
   574     aWriteStream.CommitL();
   879     }
   575     }
   880 
   576 
   881 void CFreestyleMessageHeaderHTML::AddJavascriptL() const
   577 void CFreestyleMessageHeaderHTML::AddJavascriptL( RWriteStream& aWriteStream ) const
   882     {
   578     {
   883     iWriteStream.WriteL( _L8("<script language=\"javascript\" src=\"header.js\"></script>\n"));
   579     aWriteStream.WriteL( _L8("<script language=\"javascript\" src=\"header.js\"></script>\n"));
   884     iWriteStream.CommitL();
   580     aWriteStream.CommitL();
   885     }
   581     }
   886 
   582 
   887 void CFreestyleMessageHeaderHTML::StartHeaderTableL( const TDesC8& aTableId ) const
   583 void CFreestyleMessageHeaderHTML::StartHeaderTableL( RWriteStream& aWriteStream, const TDesC8& aTableId ) const
   888     {
   584     {
   889     iWriteStream.WriteL( _L8("<table id=\"") );
   585     aWriteStream.WriteL( _L8("<table id=\"") );
   890     iWriteStream.WriteL( aTableId );
   586     aWriteStream.WriteL( aTableId );
       
   587     
   891     
   588     // use style="display:none" so that full header table is hidden initially
   892     // use style="display:none" so that full header table is hidden initially
   589     aWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\" style=\"display: none\">\n") );
   893     iWriteStream.WriteL( _L8("\" border=\"0\" width=\"100%\" style=\"display: none\">\n") );
   590     
   894     
   591     
   895     
   592     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
   896     TBuf8<KFreestyleMessageHeaderHTMLMaxBufferSizeForWidth> tableWidth;
   593     tableWidth.AppendNum( iVisibleWidth );
   897     tableWidth.AppendNum( iVisibleWidth );
   594 
   898 
   595     // Add "hide details" image as its own table with its own width
   899     // Add "hide details" image as its own table with its own width
   596     aWriteStream.WriteL( _L8("<tr><td>\n"));
   900     iWriteStream.WriteL( _L8("<tr><td>\n"));
   597     aWriteStream.WriteL(_L8("<table id =\"table_minus_icon\" border=\"0\" width=\""));
   901     iWriteStream.WriteL(_L8("<table id =\"table_minus_icon\" border=\"0\" width=\""));
   598     aWriteStream.WriteL( tableWidth );
   902     iWriteStream.WriteL( tableWidth );
   599     aWriteStream.WriteL( _L8("px\">\n"));
   903     iWriteStream.WriteL( _L8("px\">\n"));
   600     aWriteStream.WriteL( _L8("<tr>\n"));
   904     iWriteStream.WriteL( _L8("<tr>\n"));
   601     aWriteStream.WriteL( _L8("<td valign=\"top\" align=\"right\" style=\"padding: 0px 10px 0px 0px;\"><image id=\"hideDetails_img\" border=\"0\" src=\"minus.gif\" onClick=\"collapseHeader()\"></td>\n"));
   905     
   602     aWriteStream.WriteL( _L8("</tr>\n"));
   906     iWriteStream.WriteL( _L8("<td valign=\"top\""));
   603     aWriteStream.WriteL( _L8("</table></td></tr>\n"));
   907     if ( iDirectionality == TBidiText::ELeftToRight )
   604     aWriteStream.CommitL();
   908         {
   605     }
   909         iWriteStream.WriteL(_L8(" align=\"right\""));
   606 
   910         }
   607 void CFreestyleMessageHeaderHTML::EndHeaderTableL( RWriteStream& aWriteStream ) const
   911     else
   608     {
   912         {
   609     EndTableL( aWriteStream );
   913         iWriteStream.WriteL(_L8(" align=\"left\""));
   610     }
   914         }
   611 
   915     iWriteStream.WriteL( _L8(" style=\"padding: 0px 10px 0px 0px;\"><image id=\"hideDetails_img\" border=\"0\" src=\"minus.gif\" onClick=\"collapseHeader()\"></td>\n"));
   612 void CFreestyleMessageHeaderHTML::StartTableL( RWriteStream& aWriteStream, const TDesC8& aTableId ) const
   916 
   613     {
   917     iWriteStream.WriteL( _L8("</tr>\n"));
   614     aWriteStream.WriteL( _L8("<table id=\"") );
   918     iWriteStream.WriteL( _L8("</table></td></tr>\n"));
   615     aWriteStream.WriteL( aTableId );
   919     iWriteStream.CommitL();
   616     aWriteStream.WriteL( _L8("\" border=\"0\">\n") );
   920     }
   617     aWriteStream.CommitL();
   921 
   618     }
   922 void CFreestyleMessageHeaderHTML::EndHeaderTableL() const
   619 
   923     {
   620 void CFreestyleMessageHeaderHTML::EndTableL( RWriteStream& aWriteStream ) const
   924     EndTableL();
   621     {
   925     }
   622     aWriteStream.WriteL( _L8("</table>\n") );
   926 
   623     aWriteStream.CommitL();
   927 void CFreestyleMessageHeaderHTML::StartTableL( const TDesC8& aTableId ) const
   624     }
   928     {
   625 
   929     iWriteStream.WriteL( _L8("<table id=\"") );
   626 void CFreestyleMessageHeaderHTML::AddShowDetailL( RWriteStream& aWriteStream ) const
   930     iWriteStream.WriteL( aTableId );
       
   931     iWriteStream.WriteL( _L8("\" border=\"1\">\n") );
       
   932     iWriteStream.CommitL();
       
   933     }
       
   934 
       
   935 void CFreestyleMessageHeaderHTML::EndTableL() const
       
   936     {
       
   937     iWriteStream.WriteL( _L8("</table>\n") );
       
   938     iWriteStream.CommitL();
       
   939     }
       
   940 
       
   941 void CFreestyleMessageHeaderHTML::AddShowDetailL() const
   627     {
   942     {
   628     HBufC8* event = ClickImageEventL( KDetailImageName );
   943     HBufC8* event = ClickImageEventL( KDetailImageName );
   629     CleanupStack::PushL( event );
   944     CleanupStack::PushL( event );
   630     AddImageL( aWriteStream, KDetailImageName, KShowDetailIconFileName, *event );
   945     AddImageL( KDetailImageName, KShowDetailIconFileName, *event );
   631     CleanupStack::PopAndDestroy( event );
   946     CleanupStack::PopAndDestroy( event );
   632     aWriteStream.CommitL();
   947     iWriteStream.CommitL();
   633     }
   948     }
   634 
   949 
   635 HBufC8* CFreestyleMessageHeaderHTML::ClickImageEventL( const TDesC8& aImageName ) const
   950 HBufC8* CFreestyleMessageHeaderHTML::ClickImageEventL( const TDesC8& aImageName ) const
   636     {
   951     {
   637     TBuf8<KMaxEventLength> event;
   952     TBuf8<KMaxEventLength> event;
   698     CleanupStack::PopAndDestroy( headingText );
  1013     CleanupStack::PopAndDestroy( headingText );
   699     CleanupStack::PushL( headingText8 );
  1014     CleanupStack::PushL( headingText8 );
   700     return headingText8;
  1015     return headingText8;
   701     }
  1016     }
   702 
  1017 
   703 void CFreestyleMessageHeaderHTML::AddStyleSheetL( RWriteStream& aWriteStream ) const
  1018 void CFreestyleMessageHeaderHTML::AddStyleSheetL() const
   704     {
  1019     {
   705     // Add an internal style sheet
  1020     // Add an internal style sheet
   706     // If the style becomes numerous or complicated, consider using an external style sheet
  1021     // If the style becomes numerous or complicated, consider using an external style sheet
   707     
  1022     
   708     aWriteStream.WriteL( _L8("<style type=\"text/css\">\n") );
  1023     iWriteStream.WriteL( _L8("<style type=\"text/css\">\n") );
   709     
  1024     
   710     // define a div class "header", specifying the background color
  1025     // define a div class "header", specifying the background color
   711     // for the email header part
  1026     // for the email header part
   712     
  1027     
   713     // In future, query for which background color to use
  1028     // In future, query for which background color to use
   714     aWriteStream.WriteL( _L8("body { background-color: lightblue; }\n") );
  1029     iWriteStream.WriteL( _L8("body { background-color: lightblue; }\n") );
   715     
  1030     
   716     // set font size to 75% of the default size
  1031     // set font size to 75% of the default size
   717     // because, at the default size, the header text is too big relative to the text in the email body
  1032     // because, at the default size, the header text is too big relative to the text in the email body
   718     // Note: since the text in the body is too small at "normal" level, 
  1033     // Note: since the text in the body is too small at "normal" level, 
   719     // we have the text size level in the browser set to "Larger" which is 20% larger than the specified size
  1034     // we have the text size level in the browser set to "Larger" which is 20% larger than the specified size
   720     // the "larger" size affects all text which includes the header.
  1035     // the "larger" size affects all text which includes the header.
   721     aWriteStream.WriteL( _L8("td { font-family:arial,sans-serif ; font-size:75% }\n"));
  1036     iWriteStream.WriteL( _L8("td { font-family:arial,sans-serif ; font-size:75% }\n"));
   722     
  1037     
   723     aWriteStream.WriteL( _L8("</style>\n") );
  1038     iWriteStream.WriteL( _L8("</style>\n") );
   724     aWriteStream.CommitL();
  1039     iWriteStream.CommitL();
   725     }
  1040     }
   726 
  1041 
   727 void CFreestyleMessageHeaderHTML::StartDivL( RWriteStream& aWriteStream ) const
  1042 void CFreestyleMessageHeaderHTML::StartDivL() const
   728     {
  1043     {
   729     // Add div, using "header" class
  1044     // Add div, using "header" class
   730     aWriteStream.WriteL( _L8("<div class=\"header\">\n") );
  1045     iWriteStream.WriteL( _L8("<div class=\"header\">\n") );
   731     aWriteStream.CommitL();
  1046     iWriteStream.CommitL();
   732     }
  1047     }
   733     
  1048     
   734 void CFreestyleMessageHeaderHTML::EndDivL( RWriteStream& aWriteStream ) const
  1049 void CFreestyleMessageHeaderHTML::EndDivL() const
   735     {
  1050     {
   736     aWriteStream.WriteL( _L8("</div>\n") );
  1051     iWriteStream.WriteL( _L8("</div>\n") );
   737     aWriteStream.CommitL();
  1052     iWriteStream.CommitL();
   738     }
  1053     }
   739 
  1054 
   740 
  1055 
   741                                 
  1056