author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:11:15 +0300 | |
branch | RCL_3 |
changeset 80 | 726fba06891a |
parent 64 | 3533d4323edc |
permissions | -rw-r--r-- |
64 | 1 |
/* |
2 |
* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Message header HTML |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <s32strm.h> |
|
19 |
#include <f32file.h> |
|
20 |
#include <s32file.h> |
|
21 |
#include <e32cmn.h> |
|
22 |
#include <utf.h> |
|
23 |
#include <StringLoader.h> |
|
24 |
#include <AknsUtils.h> |
|
25 |
#include <AknsSkinInstance.h> |
|
26 |
#include <AknsConstants.h> |
|
27 |
||
28 |
#include <FreestyleEmailUi.rsg> |
|
29 |
#include <finditemengine.h> |
|
30 |
#include "FreestyleMessageHeaderHTML.h" |
|
31 |
#include "FreestyleEmailUiUtilities.h" |
|
32 |
#include "ncsconstants.h" |
|
33 |
||
34 |
_LIT( KAlignRight, "right" ); |
|
35 |
_LIT( KAlignLeft, "left" ); |
|
36 |
_LIT( KRtl, "rtl" ); |
|
37 |
_LIT( KLtr, "ltr" ); |
|
38 |
||
39 |
const TInt KMaxRecipientsShown( 10 ); |
|
40 |
const TInt KFreestyleMessageHeaderHTMLRightMarginInPx( 10 ); |
|
41 |
||
42 |
_LIT8( KTableRowBegin, "<tr>" ); |
|
43 |
_LIT8( KTableRowEnd, "</tr>\n" ); |
|
44 |
_LIT8( KTableCellEnd, "</td>" ); |
|
45 |
||
46 |
_LIT( KSchemeSeparator, "://" ); |
|
47 |
_LIT( KUrlFormat, "<a href=\"%S\">%S</a>" ); |
|
48 |
_LIT( KUrlFormatWithHttp, "<a href=\"http://%S\">%S</a>" ); |
|
49 |
||
50 |
_LIT( KEmpty, "" ); |
|
51 |
||
52 |
// Define this to allow theme colorin for the header |
|
53 |
#define __USE_THEME_COLOR_FOR_HEADER |
|
54 |
||
55 |
EXPORT_C CFreestyleMessageHeaderHTML* CFreestyleMessageHeaderHTML::NewL( CFSMailMessage& aMailMessage, |
|
56 |
RWriteStream& aWriteStream, |
|
57 |
TInt aVisibleWidth, |
|
58 |
TInt aScrollPosition, |
|
59 |
const TBool aAutoLoadImages, |
|
60 |
const TBitFlags& aFlags |
|
61 |
) |
|
62 |
{ |
|
63 |
CFreestyleMessageHeaderHTML* self = new (ELeave) CFreestyleMessageHeaderHTML( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aAutoLoadImages, aFlags); |
|
64 |
self->ConstructL(); |
|
65 |
return self; |
|
66 |
} |
|
67 |
||
68 |
EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, |
|
69 |
RWriteStream& aWriteStream, |
|
70 |
TInt aVisibleWidth, |
|
71 |
TInt aScrollPosition, |
|
72 |
const TBool aAutoLoadImages, |
|
73 |
const TBitFlags& aFlags ) |
|
74 |
{ |
|
75 |
CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, aWriteStream, aVisibleWidth, aScrollPosition, aAutoLoadImages, aFlags); |
|
76 |
CleanupStack::PushL( headerHtml ); |
|
77 |
headerHtml->ExportL(); |
|
78 |
CleanupStack::PopAndDestroy( headerHtml ); |
|
79 |
} |
|
80 |
||
81 |
EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, |
|
82 |
RFile& aFile, |
|
83 |
TInt aVisibleWidth, |
|
84 |
TInt aScrollPosition, |
|
85 |
const TBool aAutoLoadImages, |
|
86 |
const TBitFlags& aFlags ) |
|
87 |
{ |
|
88 |
RFileWriteStream fwstream; |
|
89 |
fwstream.Attach( aFile, 0 ); |
|
90 |
CleanupClosePushL( fwstream ); |
|
91 |
||
92 |
CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aAutoLoadImages, aFlags ); |
|
93 |
CleanupStack::PushL( headerHtml ); |
|
94 |
headerHtml->ExportL(); |
|
95 |
CleanupStack::PopAndDestroy( headerHtml ); |
|
96 |
||
97 |
CleanupStack::PopAndDestroy( &fwstream ); |
|
98 |
} |
|
99 |
||
100 |
EXPORT_C void CFreestyleMessageHeaderHTML::ExportL( CFSMailMessage& aMailMessage, |
|
101 |
RFs& aFs, |
|
102 |
const TPath& aFilePath, |
|
103 |
TInt aVisibleWidth, |
|
104 |
TInt aScrollPosition, |
|
105 |
const TBool aAutoLoadImages, |
|
106 |
const TBitFlags& aFlags ) |
|
107 |
{ |
|
108 |
RFileWriteStream fwstream; |
|
109 |
User::LeaveIfError( fwstream.Replace( aFs, aFilePath, EFileStreamText | EFileWrite) ); |
|
110 |
CleanupClosePushL( fwstream ); |
|
111 |
||
112 |
CFreestyleMessageHeaderHTML* headerHtml = CFreestyleMessageHeaderHTML::NewL( aMailMessage, fwstream, aVisibleWidth, aScrollPosition, aAutoLoadImages, aFlags); |
|
113 |
CleanupStack::PushL( headerHtml ); |
|
114 |
headerHtml->ExportL(); |
|
115 |
CleanupStack::PopAndDestroy( headerHtml ); |
|
116 |
||
117 |
CleanupStack::PopAndDestroy( &fwstream ); |
|
118 |
} |
|
119 |
||
120 |
CFreestyleMessageHeaderHTML::~CFreestyleMessageHeaderHTML() |
|
121 |
{ |
|
122 |
iAttachments.ResetAndDestroy(); |
|
123 |
} |
|
124 |
||
125 |
CFreestyleMessageHeaderHTML::CFreestyleMessageHeaderHTML( CFSMailMessage& aMailMessage, |
|
126 |
RWriteStream& aWriteStream, |
|
127 |
TInt aVisibleWidth, |
|
128 |
TInt aScrollPosition, |
|
129 |
const TBool aAutoLoadImages, |
|
130 |
const TBitFlags& aFlags ) |
|
131 |
: iMailMessage( aMailMessage ), |
|
132 |
iWriteStream( aWriteStream ), |
|
133 |
iVisibleWidth( aVisibleWidth - KFreestyleMessageHeaderHTMLRightMarginInPx ), |
|
134 |
iScrollPosition( aScrollPosition ), |
|
135 |
iExportFlags( aFlags ) |
|
136 |
{ |
|
137 |
iExportFlags.Assign( EAutoLoadImages, aAutoLoadImages ); |
|
138 |
iExportFlags.Assign( EMirroredLayout, AknLayoutUtils::LayoutMirrored() ); |
|
139 |
} |
|
140 |
||
141 |
void CFreestyleMessageHeaderHTML::ConstructL() |
|
142 |
{ |
|
143 |
iMailMessage.AttachmentListL( iAttachments ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
144 |
// Remove attachments with no name |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
145 |
for ( TInt i = iAttachments.Count() - 1; i >= 0; i-- ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
146 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
147 |
if ( !iAttachments[i]->AttachmentNameL().Length() ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
148 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
149 |
iAttachments.Remove( i ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
150 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
151 |
} |
64 | 152 |
} |
153 |
||
154 |
EXPORT_C void CFreestyleMessageHeaderHTML::ExportL() const |
|
155 |
{ |
|
156 |
ExportBodyStyleL(); |
|
157 |
ExportHTMLBodyStartL(); |
|
158 |
ExportHeaderTablesL(); |
|
159 |
ExportHTMLBodyEndL(); |
|
160 |
} |
|
161 |
||
162 |
void CFreestyleMessageHeaderHTML::ExportHTMLBodyStartL() const |
|
163 |
{ |
|
164 |
_LIT( KHtmlBodyStart, "<html dir=\"%S\" xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<title>Email Header</title>\n<script language=\"javascript\" src=\"header.js\"></script>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"header.css\"/>\n</head>\n<body onLoad = \"init(%d)\">\n" ); |
|
165 |
//_LIT( KHtmlBodyStart, "<html dir=\"%S\" xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<title>Email Header</title>\n<script language=\"javascript\" src=\"header.js\"></script>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"header%d.css\"/>\n</head>\n<body onLoad = \"init(%d)\">\n" ); |
|
166 |
const TPtrC direction( iExportFlags.IsSet( EMirroredLayout ) ? KRtl() : KLtr() ); |
|
167 |
HBufC* formatBuffer = HBufC::NewLC( KHtmlBodyStart().Length() + direction.Length() + 16 ); |
|
168 |
formatBuffer->Des().Format( KHtmlBodyStart(), &direction, iScrollPosition ); |
|
169 |
//formatBuffer->Des().Format( KHtmlBodyStart(), &direction, Math::Random() % 2, iScrollPosition ); |
|
170 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
171 |
CleanupStack::PushL( utf ); |
|
172 |
iWriteStream.WriteL( *utf ); |
|
173 |
CleanupStack::PopAndDestroy( 2 ); // formatBuffer, utf |
|
174 |
iWriteStream.CommitL(); |
|
175 |
} |
|
176 |
||
177 |
void CFreestyleMessageHeaderHTML::ExportInnerTableBeginWithRowBeginL( const TDesC& aTableName, const TInt aColSpan, |
|
178 |
const TBool aVisible, const TBitFlags& aFlags ) const |
|
179 |
{ |
|
180 |
iWriteStream.WriteL( KTableRowBegin() ); |
|
181 |
ExportTableVisibilityParameterL( aTableName, aVisible ); |
|
182 |
ExportInnerTableBeginL( aTableName, aColSpan, aFlags ); |
|
183 |
} |
|
184 |
||
185 |
||
186 |
void CFreestyleMessageHeaderHTML::ExportInnerTableBeginL( const TDesC& aTableName, const TInt aColSpan, |
|
187 |
const TBitFlags& aFlags ) const |
|
188 |
{ |
|
189 |
_LIT( KHidden, " style=\"display: none;\""); |
|
190 |
_LIT( KFixed, " class=\"fixed\""); |
|
191 |
_LIT( KTableHeader, "<td colspan=\"%d\"><table id=\"%S\" width=\"100%%\"%S%S>\n" ); |
|
192 |
const TPtrC style( aFlags.IsClear( EHidden ) ? KNullDesC() : KHidden() ); |
|
193 |
const TPtrC fixed( aFlags.IsClear( EFixed ) ? KNullDesC() : KFixed() ); |
|
194 |
HBufC* formatBuffer = HBufC::NewLC( KTableHeader().Length() + aTableName.Length() + 16 + style.Length() + fixed.Length() ); |
|
195 |
formatBuffer->Des().Format( KTableHeader(), aColSpan, &aTableName, &style, &fixed ); |
|
196 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
197 |
CleanupStack::PushL( utf ); |
|
198 |
iWriteStream.WriteL( *utf ); |
|
199 |
CleanupStack::PopAndDestroy( 2 ); // formatBuffer, utf |
|
200 |
} |
|
201 |
||
202 |
void CFreestyleMessageHeaderHTML::ExportTableVisibilityParameterL( const TDesC& aTableName, const TBitFlags& aFlags ) const |
|
203 |
{ |
|
204 |
ExportTableVisibilityParameterL( aTableName, aFlags.IsClear( EHidden ) ); |
|
205 |
} |
|
206 |
||
207 |
void CFreestyleMessageHeaderHTML::ExportTableVisibilityParameterL( const TDesC& aTableName, const TBool aVisible ) const |
|
208 |
{ |
|
209 |
_LIT( KTrue, "true" ); |
|
210 |
_LIT( KFalse, "false" ); |
|
211 |
_LIT( KVisibilityParameter, "<script type=\"text/javascript\">var is_%S_visible=%S;</script>" ); |
|
212 |
const TPtrC visible( aVisible ? KTrue() : KFalse() ); |
|
213 |
HBufC* formatBuffer = HBufC::NewLC( KVisibilityParameter().Length() + aTableName.Length() + visible.Length() ); |
|
214 |
formatBuffer->Des().Format( KVisibilityParameter(), &aTableName, &visible ); |
|
215 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
216 |
CleanupStack::PushL( utf ); |
|
217 |
iWriteStream.WriteL( *utf ); |
|
218 |
CleanupStack::PopAndDestroy( 2 ); // formatBuffer, utf |
|
219 |
} |
|
220 |
||
221 |
void CFreestyleMessageHeaderHTML::ExportTableBeginL( const TDesC& aTableName, const TBitFlags& aFlags ) const |
|
222 |
{ |
|
223 |
_LIT( KFixed, " class=\"fixed\""); |
|
224 |
_LIT( KTableHeader, "<table id=\"%S\" width=\"%dpx\"%S%S>\n" ); |
|
225 |
const TPtrC style( aFlags.IsClear( EHidden ) ? KNullDesC() : KNullDesC() ); |
|
226 |
const TPtrC fixed( aFlags.IsClear( EFixed ) ? KNullDesC() : KFixed() ); |
|
227 |
ExportTableVisibilityParameterL( aTableName, aFlags ); |
|
228 |
HBufC* formatBuffer = HBufC::NewLC( KTableHeader().Length() + aTableName.Length() + 16 + style.Length() + fixed.Length() ); |
|
229 |
formatBuffer->Des().Format( KTableHeader(), &aTableName, iVisibleWidth, &style, &fixed ); |
|
230 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
231 |
CleanupStack::PushL( utf ); |
|
232 |
iWriteStream.WriteL( *utf ); |
|
233 |
CleanupStack::PopAndDestroy( 2 ); // formatBuffer, utf |
|
234 |
} |
|
235 |
||
236 |
void CFreestyleMessageHeaderHTML::ExportInnerTableEndL() const |
|
237 |
{ |
|
238 |
ExportTableEndL(); |
|
239 |
iWriteStream.WriteL( KTableCellEnd() ); |
|
240 |
} |
|
241 |
||
242 |
void CFreestyleMessageHeaderHTML::ExportInnerTableEndWithRowEndL() const |
|
243 |
{ |
|
244 |
ExportInnerTableEndL(); |
|
245 |
iWriteStream.WriteL( KTableRowEnd() ); |
|
246 |
} |
|
247 |
||
248 |
void CFreestyleMessageHeaderHTML::ExportTableEndL() const |
|
249 |
{ |
|
250 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( _L("</table>\n") ); |
|
251 |
CleanupStack::PushL( utf ); |
|
252 |
iWriteStream.WriteL( *utf ); |
|
253 |
CleanupStack::PopAndDestroy(); // utf |
|
254 |
} |
|
255 |
||
256 |
void CFreestyleMessageHeaderHTML::ExportSenderTableRowL( const TBool aCollapsed ) const |
|
257 |
{ |
|
258 |
_LIT( KStyleExpand, "expand" ); |
|
259 |
_LIT( KStyleCollapse, "collapse" ); |
|
260 |
_LIT( KExpandFunction, "expandHeader(true)" ); |
|
261 |
_LIT( KCollapseFunction, "collapseHeader(true)" ); |
|
262 |
_LIT( KSenderFormat, "<tr><td align=\"%S\" class=\"sender_name\"><div class=\"truncate\">%S</div></td><td valign=\"top\" rowSpan=\"2\" class=\"button_cell\"><button value=\"submit\" onClick=\"%S\" class=\"%S\"></button></td></tr>\n" ); |
|
263 |
const CFSMailAddress* sender( iMailMessage.GetSender() ); |
|
264 |
||
265 |
TPtrC displayName; |
|
266 |
if ( sender ) |
|
267 |
{ |
|
268 |
displayName.Set( sender->GetDisplayName() ); |
|
269 |
if ( !displayName.Length() ) |
|
270 |
{ |
|
271 |
displayName.Set( sender->GetEmailAddress() ); |
|
272 |
} |
|
273 |
} |
|
274 |
else |
|
275 |
{ |
|
276 |
displayName.Set( KEmpty ); |
|
277 |
} |
|
278 |
||
279 |
const TPtrC function( aCollapsed ? KExpandFunction() : KCollapseFunction() ); |
|
280 |
const TPtrC style( aCollapsed ? KStyleExpand() : KStyleCollapse() ); |
|
281 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
282 |
HBufC* formatBuffer = HBufC::NewLC( KSenderFormat().Length() + displayName.Length() + align.Length() + function.Length() + style.Length() ); |
|
283 |
formatBuffer->Des().Format( KSenderFormat(), &align, &displayName, &function, &style ); |
|
284 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
285 |
CleanupStack::PushL( utf ); |
|
286 |
iWriteStream.WriteL( *utf ); |
|
287 |
CleanupStack::PopAndDestroy( 2 ); // formatBuffer, utf |
|
288 |
} |
|
289 |
||
290 |
void CFreestyleMessageHeaderHTML::ExportSenderAddressTableRowL() const |
|
291 |
{ |
|
292 |
_LIT( KSenderAddressFormat, "<tr><td colspan=\"2\" align=\"%S\"><div class=\"truncate\"><a class=\"sender_address\" href=\"cmail://from/%S\">%S</a></div></td></tr>\n" ); |
|
293 |
const CFSMailAddress* sender( iMailMessage.GetSender() ); |
|
294 |
||
295 |
TPtrC emailAddress; |
|
296 |
if ( sender ) |
|
297 |
{ |
|
298 |
emailAddress.Set( sender->GetEmailAddress() ); |
|
299 |
} |
|
300 |
else |
|
301 |
{ |
|
302 |
emailAddress.Set( KEmpty ); |
|
303 |
} |
|
304 |
||
305 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
306 |
HBufC* formatBuffer = HBufC::NewLC( KSenderAddressFormat().Length() + emailAddress.Length() * 2 + align.Length() ); |
|
307 |
formatBuffer->Des().Format( KSenderAddressFormat(), &align, &emailAddress, &emailAddress ); |
|
308 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
309 |
CleanupStack::PushL( utf ); |
|
310 |
iWriteStream.WriteL( *utf ); |
|
311 |
CleanupStack::PopAndDestroy( 2 ); // formatBuffer, utf |
|
312 |
} |
|
313 |
||
314 |
void CFreestyleMessageHeaderHTML::ExportLabelTableRowL( const TInt aResourceId, const TInt aColSpan ) const |
|
315 |
{ |
|
316 |
_LIT( KLabelFormat, "<tr><td align=\"%S\" colspan=\"%d\" class=\"label\">%S</td></tr>\n" ); |
|
317 |
HBufC* labelText = StringLoader::LoadLC( aResourceId ); |
|
318 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
319 |
HBufC* formatBuffer = HBufC::NewLC( KLabelFormat().Length() + labelText->Length() + align.Length() + 8 ); |
|
320 |
formatBuffer->Des().Format( KLabelFormat(), &align, aColSpan, labelText ); |
|
321 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
322 |
CleanupStack::PushL( utf ); |
|
323 |
iWriteStream.WriteL( *utf ); |
|
324 |
CleanupStack::PopAndDestroy( 3 ); // labelText, formatBuffer, utf |
|
325 |
} |
|
326 |
||
327 |
void CFreestyleMessageHeaderHTML::ExportFromTableRowL() const |
|
328 |
{ |
|
329 |
ExportLabelTableRowL( R_FREESTYLE_EMAIL_UI_VIEWER_FROM ); |
|
330 |
ExportSenderAddressTableRowL(); |
|
331 |
} |
|
332 |
||
333 |
void CFreestyleMessageHeaderHTML::ExportExpandRecipientsL( const TDesC& aType, const TInt aCount ) const |
|
334 |
{ |
|
335 |
_LIT( KExpandRecipientsFormat, "<tr><td align=\"%S\"><a class=\"recipient\" href=\"cmail://expand_%S/\" onclick=\"handleHeaderDisplay('%S_collapsed','%S_expanded')\">%S</a></td></tr>\n" ); |
|
336 |
HBufC* text = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEWER_N_MORE_RECIPIENTS, aCount ); |
|
337 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
338 |
HBufC* formatBuffer = HBufC::NewLC( KExpandRecipientsFormat().Length() + text->Length() + align.Length() + aType.Length() * 3 ); |
|
339 |
formatBuffer->Des().Format( KExpandRecipientsFormat(), &align, &aType, &aType, &aType, text ); |
|
340 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
341 |
CleanupStack::PushL( utf ); |
|
342 |
iWriteStream.WriteL( *utf ); |
|
343 |
CleanupStack::PopAndDestroy( 3 ); // text, formatBuffer, utf |
|
344 |
} |
|
345 |
||
346 |
void CFreestyleMessageHeaderHTML::ExportExpandAttachmentsL( const TDesC& aType, const TInt aCount ) const |
|
347 |
{ |
|
348 |
_LIT( KExpandRecipientsFormat, "<td align=\"%S\" class=\"attachment\"><a href=\"cmail://expand_%S/\" onclick=\"handleHeaderDisplay('%S_collapsed','%S_expanded')\">%S</a></td>" ); |
|
349 |
HBufC* text = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_TEXT, aCount ); |
|
350 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
351 |
HBufC* formatBuffer = HBufC::NewLC( KExpandRecipientsFormat().Length() + text->Length() + align.Length() + aType.Length() * 3 ); |
|
352 |
formatBuffer->Des().Format( KExpandRecipientsFormat(), &align, &aType, &aType, &aType, text ); |
|
353 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
354 |
CleanupStack::PushL( utf ); |
|
355 |
iWriteStream.WriteL( *utf ); |
|
356 |
CleanupStack::PopAndDestroy( 3 ); // text, formatBuffer, utf |
|
357 |
} |
|
358 |
||
359 |
void CFreestyleMessageHeaderHTML::ExportRecipientsTableL( const TDesC& aType, const TInt aLabelResourceId, |
|
360 |
const RPointerArray<CFSMailAddress>& aRecipients, const TBool aExpanded ) const |
|
361 |
{ |
|
362 |
if ( aRecipients.Count() > 0 ) |
|
363 |
{ |
|
364 |
TBool innerTableExpanded( aExpanded ); |
|
365 |
TBitFlags flags; |
|
366 |
flags.Assign( EHidden, iExportFlags.IsClear( EHeaderExpanded ) ); |
|
367 |
_LIT( KTableNameFormat, "%S_table" ); |
|
368 |
HBufC* outerTableName = HBufC::NewLC( KTableNameFormat().Length() + aType.Length() ); |
|
369 |
outerTableName->Des().Format( KTableNameFormat(), &aType ); |
|
370 |
ExportTableBeginL( *outerTableName, flags ); |
|
371 |
CleanupStack::PopAndDestroy(); // outerTableName |
|
372 |
||
373 |
ExportLabelTableRowL( aLabelResourceId, 2 ); |
|
374 |
const TBool showCollapsed( aRecipients.Count() > KMaxRecipientsShown ); |
|
375 |
TBitFlags tableFlags; |
|
376 |
tableFlags.Set( EFixed ); |
|
377 |
if ( showCollapsed ) |
|
378 |
{ |
|
379 |
_LIT( KFormatCollapsed, "%S_collapsed" ); |
|
380 |
HBufC* tableName = HBufC::NewLC( KFormatCollapsed().Length() + 8 ); |
|
381 |
tableName->Des().Format( KFormatCollapsed(), &aType ); |
|
382 |
ExportInnerTableBeginWithRowBeginL( *tableName, 2, !innerTableExpanded, tableFlags ); |
|
383 |
CleanupStack::PopAndDestroy(); // tableName |
|
384 |
ExportExpandRecipientsL( aType, aRecipients.Count() ); |
|
385 |
ExportInnerTableEndWithRowEndL(); |
|
386 |
tableFlags.Set( EHidden ); |
|
387 |
} |
|
388 |
else |
|
389 |
{ |
|
390 |
innerTableExpanded = ETrue; |
|
391 |
} |
|
392 |
_LIT( KFormatExpanded, "%S_expanded" ); |
|
393 |
HBufC* tableName = HBufC::NewLC( KFormatExpanded().Length() + 8 ); |
|
394 |
tableName->Des().Format( KFormatExpanded(), &aType ); |
|
395 |
ExportInnerTableBeginWithRowBeginL( *tableName, 2, innerTableExpanded, tableFlags ); |
|
396 |
CleanupStack::PopAndDestroy(); // tableName |
|
397 |
ExportRecipientsL( aType, aRecipients ); |
|
398 |
ExportInnerTableEndWithRowEndL(); |
|
399 |
ExportTableEndL(); |
|
400 |
} |
|
401 |
} |
|
402 |
||
403 |
void CFreestyleMessageHeaderHTML::ExportRecipientsL( const TDesC& aType, |
|
404 |
const RPointerArray<CFSMailAddress>& aRecipients) const |
|
405 |
{ |
|
406 |
_LIT( KRecipientFormat, "<tr><td align=\"%S\"><div class=\"truncate\"><a class=\"recipient\" href=\"cmail://%S/%S\">%S</a></div></td></tr>" ); |
|
407 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
408 |
for ( TInt i = 0; i < aRecipients.Count(); i++ ) |
|
409 |
{ |
|
410 |
const CFSMailAddress* sender( aRecipients[ i ] ); |
|
411 |
TPtrC displayName( sender->GetDisplayName() ); |
|
412 |
const TPtrC emailAddress( sender->GetEmailAddress() ); |
|
413 |
if ( !displayName.Length() ) |
|
414 |
{ |
|
415 |
displayName.Set( emailAddress ); |
|
416 |
} |
|
417 |
HBufC* formatBuffer = HBufC::NewLC( KRecipientFormat().Length() + align.Length() + aType.Length() + emailAddress.Length() + displayName.Length() ); |
|
418 |
formatBuffer->Des().Format( KRecipientFormat(), &align, &aType, &emailAddress, &displayName ); |
|
419 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
420 |
CleanupStack::PushL( utf ); |
|
421 |
iWriteStream.WriteL( *utf ); |
|
422 |
CleanupStack::PopAndDestroy( 2 ); // formatBuffer, utf |
|
423 |
} |
|
424 |
} |
|
425 |
||
426 |
void CFreestyleMessageHeaderHTML::ExportToTableL() const |
|
427 |
{ |
|
428 |
ExportRecipientsTableL( _L("to"), R_FREESTYLE_EMAIL_UI_VIEWER_TO, iMailMessage.GetToRecipients(), iExportFlags.IsSet( EToExpanded ) ); |
|
429 |
} |
|
430 |
||
431 |
void CFreestyleMessageHeaderHTML::ExportCcTableL() const |
|
432 |
{ |
|
433 |
ExportRecipientsTableL( _L("cc"), R_FREESTYLE_EMAIL_UI_VIEWER_CC, iMailMessage.GetCCRecipients(), iExportFlags.IsSet( ECcExpanded ) ); |
|
434 |
} |
|
435 |
||
436 |
void CFreestyleMessageHeaderHTML::ExportBccTableL() const |
|
437 |
{ |
|
438 |
ExportRecipientsTableL( _L("bcc"), R_FREESTYLE_EMAIL_UI_VIEWER_BCC, iMailMessage.GetBCCRecipients(), iExportFlags.IsSet( EBccExpanded ) ); |
|
439 |
} |
|
440 |
||
441 |
void CFreestyleMessageHeaderHTML::ExportDateTimeTableRowL( const TInt aColSpan ) const |
|
442 |
{ |
|
443 |
_LIT( KDateTimeFormat, "<tr><td colspan=\"%d\" align=\"%S\" class=\"datetime\">%S%S%S</td></tr>\n" ); |
|
444 |
HBufC* dateText = TFsEmailUiUtility::DateTextFromMsgLC( &iMailMessage ); |
|
445 |
HBufC* timeText = TFsEmailUiUtility::TimeTextFromMsgLC( &iMailMessage ); |
|
446 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
447 |
HBufC* formatBuffer = HBufC::NewLC( KDateTimeFormat().Length() + dateText->Length() + timeText->Length() + KSentLineDateAndTimeSeparatorText().Length() + align.Length() + 3 ); |
|
448 |
formatBuffer->Des().Format( KDateTimeFormat(), aColSpan, &align, dateText, &KSentLineDateAndTimeSeparatorText(), timeText ); |
|
449 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
450 |
CleanupStack::PushL( utf ); |
|
451 |
iWriteStream.WriteL( *utf ); |
|
452 |
CleanupStack::PopAndDestroy( 4 ); // dateText, timeText, formatBuffer, utf |
|
453 |
} |
|
454 |
||
455 |
void CFreestyleMessageHeaderHTML::ExportSubjectTableRowL( const TBool aShowLabel ) const |
|
456 |
{ |
|
457 |
_LIT( KClassSubject, "subject" ); |
|
458 |
TPtrC subjectClass( KClassSubject() ); |
|
459 |
if ( aShowLabel ) |
|
460 |
{ |
|
461 |
_LIT( KClassSubjectIntended, "subject_intended"); |
|
462 |
ExportLabelTableRowL( R_FREESTYLE_EMAIL_UI_VIEWER_SUBJECT, 2 ); |
|
463 |
subjectClass.Set( KClassSubjectIntended() ); |
|
464 |
} |
|
465 |
_LIT( KSubjectFormat, "<tr><td align=\"%S\" class=\"%S\">%S</td><td align=\"center\" valign=\"bottom\" width=\"1\">"); |
|
466 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
467 |
HBufC* subject = SubjectLC(); |
|
468 |
HBufC* formatBuffer = HBufC::NewLC( KSubjectFormat().Length() + align.Length() + subject->Length() + subjectClass.Length() ); |
|
469 |
formatBuffer->Des().Format( KSubjectFormat(), &align, &subjectClass, subject ); |
|
470 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
471 |
CleanupStack::PushL( utf ); |
|
472 |
iWriteStream.WriteL( *utf ); |
|
473 |
CleanupStack::PopAndDestroy( 3 ); // subject, formatBuffer, utf |
|
474 |
ExportMessageIconsL(); |
|
475 |
iWriteStream.WriteL( KTableCellEnd() ); |
|
476 |
iWriteStream.WriteL( KTableRowEnd() ); |
|
477 |
} |
|
478 |
||
479 |
void CFreestyleMessageHeaderHTML::ExportMessageIconsL() const |
|
480 |
{ |
|
481 |
_LIT( KPriorityLow, "priority_low" ); |
|
482 |
_LIT( KPriorityHigh, "priority_high" ); |
|
483 |
_LIT( KFollowUp, "follow_up" ); |
|
484 |
_LIT( KFollowUpComplete, "follow_up_complete" ); |
|
485 |
||
486 |
TBool iconShown( EFalse ); |
|
487 |
||
488 |
if ( iMailMessage.IsFlagSet( EFSMsgFlag_Low ) ) |
|
489 |
{ |
|
490 |
ExportIconL( KPriorityLow() ); |
|
491 |
iconShown = ETrue; |
|
492 |
} |
|
493 |
else if ( iMailMessage.IsFlagSet( EFSMsgFlag_Important ) ) |
|
494 |
{ |
|
495 |
ExportIconL( KPriorityHigh() ); |
|
496 |
iconShown = ETrue; |
|
497 |
} |
|
498 |
||
499 |
if ( iMailMessage.IsFlagSet( EFSMsgFlag_FollowUp ) ) |
|
500 |
{ |
|
501 |
ExportIconL( KFollowUp() ); |
|
502 |
iconShown = ETrue; |
|
503 |
} |
|
504 |
else if ( iMailMessage.IsFlagSet( EFSMsgFlag_FollowUpComplete ) ) |
|
505 |
{ |
|
506 |
ExportIconL( KFollowUpComplete() ); |
|
507 |
iconShown = ETrue; |
|
508 |
} |
|
509 |
if ( iconShown ) |
|
510 |
{ |
|
511 |
iWriteStream.WriteL( _L8("<div class=\"icon_cell\"></div>") ); |
|
512 |
} |
|
513 |
} |
|
514 |
||
515 |
void CFreestyleMessageHeaderHTML::ExportHeaderTablesL() const |
|
516 |
{ |
|
517 |
ExportCollapsedHeaderTableL(); |
|
518 |
ExportExpandedHeaderTablesL(); |
|
519 |
ExportAttachmentTablesL(); |
|
520 |
ExportDisplayImagesTableL(); |
|
521 |
} |
|
522 |
||
523 |
void CFreestyleMessageHeaderHTML::ExportCollapsedHeaderTableL() const |
|
524 |
{ |
|
525 |
TBitFlags flags; |
|
526 |
flags.Set( EFixed ); |
|
527 |
flags.Assign( EHidden, iExportFlags.IsSet( EHeaderExpanded ) ); |
|
528 |
ExportTableBeginL( _L("header_collapsed"), flags ); |
|
529 |
ExportSenderTableRowL( ETrue ); |
|
530 |
ExportDateTimeTableRowL(); |
|
531 |
ExportTableEndL(); |
|
532 |
flags.Clear( EFixed ); |
|
533 |
ExportTableBeginL( _L("header_collapsed_2"), flags ); |
|
534 |
ExportSubjectTableRowL(); |
|
535 |
ExportTableEndL(); |
|
536 |
iWriteStream.CommitL(); |
|
537 |
} |
|
538 |
||
539 |
void CFreestyleMessageHeaderHTML::ExportExpandedHeaderTablesL() const |
|
540 |
{ |
|
541 |
TBitFlags flags; |
|
542 |
flags.Set( EFixed ); |
|
543 |
flags.Assign( EHidden, iExportFlags.IsClear( EHeaderExpanded ) ); |
|
544 |
ExportTableBeginL( _L("header_expanded"), flags ); |
|
545 |
ExportSenderTableRowL( EFalse ); |
|
546 |
ExportFromTableRowL(); |
|
547 |
ExportTableEndL(); |
|
548 |
ExportToTableL(); |
|
549 |
ExportCcTableL(); |
|
550 |
ExportBccTableL(); |
|
551 |
flags.Clear( EFixed ); |
|
552 |
ExportTableBeginL( _L("header_expanded_2"), flags ); |
|
553 |
ExportDateTimeTableRowL( 2 ); |
|
554 |
ExportSubjectTableRowL(); |
|
555 |
ExportTableEndL(); |
|
556 |
iWriteStream.CommitL(); |
|
557 |
} |
|
558 |
||
559 |
void CFreestyleMessageHeaderHTML::ExportAttachmentTablesL() const |
|
560 |
{ |
|
561 |
const TInt attachmentCount( iAttachments.Count() ); |
|
562 |
if ( attachmentCount ) |
|
563 |
{ |
|
564 |
if ( attachmentCount > 1 ) |
|
565 |
{ |
|
566 |
ExportCollapsedAttachmentTableL( iExportFlags.IsSet( EAttachmentExpanded ) ); |
|
567 |
ExportExpandedAttachmentTableL( iExportFlags.IsClear( EAttachmentExpanded ) ); |
|
568 |
} |
|
569 |
else |
|
570 |
{ |
|
571 |
ExportExpandedAttachmentTableL( EFalse ); |
|
572 |
} |
|
573 |
} |
|
574 |
} |
|
575 |
||
576 |
void CFreestyleMessageHeaderHTML::ExportAttachmentIconL() const |
|
577 |
{ |
|
578 |
_LIT8( KCellBegin, "<td width=\"1\" valign=\"top\" class=\"attachment\">" ); |
|
579 |
iWriteStream.WriteL( KCellBegin() ); |
|
580 |
_LIT( KAttachment, "attachment" ); |
|
581 |
ExportIconL( KAttachment() ); |
|
582 |
iWriteStream.WriteL( KTableCellEnd() ); |
|
583 |
} |
|
584 |
||
585 |
void CFreestyleMessageHeaderHTML::ExportCollapsedAttachmentTableL( const TBool aHide ) const |
|
586 |
{ |
|
587 |
TBitFlags flags; |
|
588 |
flags.Assign( EHidden, aHide ); |
|
589 |
ExportTableBeginL( _L("attachments_collapsed"), flags ); |
|
590 |
ExportCollapsedAttachmentsTableRowL(); |
|
591 |
ExportTableEndL(); |
|
592 |
} |
|
593 |
||
594 |
void CFreestyleMessageHeaderHTML::ExportCollapsedAttachmentsTableRowL() const |
|
595 |
{ |
|
596 |
iWriteStream.WriteL( KTableRowBegin() ); |
|
597 |
ExportAttachmentIconL(); |
|
598 |
ExportExpandAttachmentsL( _L("attachments"), iAttachments.Count() ); |
|
599 |
iWriteStream.WriteL( KTableRowEnd() ); |
|
600 |
} |
|
601 |
||
602 |
void CFreestyleMessageHeaderHTML::ExportExpandedAttachmentTableL( const TBool aHide ) const |
|
603 |
{ |
|
604 |
TBitFlags flags; |
|
605 |
flags.Assign( EHidden, aHide ); |
|
606 |
ExportTableBeginL( _L("attachments_expanded"), flags ); |
|
607 |
ExportExpandedAttachmentsTableRowsL(); |
|
608 |
ExportTableEndL(); |
|
609 |
} |
|
610 |
||
611 |
void CFreestyleMessageHeaderHTML::ExportExpandedAttachmentsTableRowsL() const |
|
612 |
{ |
|
613 |
iWriteStream.WriteL( KTableRowBegin() ); |
|
614 |
ExportAttachmentIconL(); |
|
615 |
ExportAttachmentsL(); |
|
616 |
iWriteStream.WriteL( KTableRowEnd() ); |
|
617 |
} |
|
618 |
||
619 |
void CFreestyleMessageHeaderHTML::ExportAttachmentsL() const |
|
620 |
{ |
|
621 |
ExportInnerTableBeginL( _L("_attachments_expanded"), 1 ); |
|
622 |
for ( TInt i = 0; i < iAttachments.Count(); i++ ) |
|
623 |
{ |
|
624 |
ExportAttachmentL( *iAttachments[ i ] ); |
|
625 |
} |
|
626 |
ExportInnerTableEndL(); |
|
627 |
} |
|
628 |
||
629 |
void CFreestyleMessageHeaderHTML::ExportAttachmentL( CFSMailMessagePart& aAttachment ) const |
|
630 |
{ |
|
631 |
_LIT( KAttachmentFormat, "<tr><td align=\"%S\" class=\"attachment\"><a href=\"cmail://attachment/%d\">%S (%S)</a></td></tr>\n" ); |
|
632 |
const TPtrC align( iExportFlags.IsSet( EMirroredLayout ) ? KAlignRight() : KAlignLeft() ); |
|
633 |
HBufC* size = TFsEmailUiUtility::CreateSizeDescLC( aAttachment.ContentSize(), EFalse ); |
|
634 |
const TPtrC attachmentName( aAttachment.AttachmentNameL() ); |
|
635 |
HBufC* formatBuffer = HBufC::NewLC( KAttachmentFormat().Length() + align.Length() + size->Length() + attachmentName.Length() + 16 ); |
|
636 |
formatBuffer->Des().Format( KAttachmentFormat(), &align, aAttachment.GetPartId().Id(), &attachmentName, size ); |
|
637 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
638 |
CleanupStack::PushL( utf ); |
|
639 |
iWriteStream.WriteL( *utf ); |
|
640 |
CleanupStack::PopAndDestroy( 3 ); // size, formatBuffer, utf |
|
641 |
} |
|
642 |
||
643 |
void CFreestyleMessageHeaderHTML::ExportIconL( const TDesC& aIconName ) const |
|
644 |
{ |
|
645 |
_LIT( KMessageIconFormat, "<img src=\"%S.png\" class=\"icon\"/>" ); |
|
646 |
HBufC* formatBuffer = HBufC::NewLC( KMessageIconFormat().Length() + aIconName.Length() ); |
|
647 |
formatBuffer->Des().Format( KMessageIconFormat(), &aIconName ); |
|
648 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
649 |
CleanupStack::PushL( utf ); |
|
650 |
iWriteStream.WriteL( *utf ); |
|
651 |
CleanupStack::PopAndDestroy( 2 ); // formatBuffer, utf |
|
652 |
} |
|
653 |
||
654 |
HBufC* CFreestyleMessageHeaderHTML::SubjectLC() const |
|
655 |
{ |
|
656 |
return CreateLinksLC( iMailMessage.GetSubject(), CFindItemEngine::EFindItemSearchURLBin ); |
|
657 |
} |
|
658 |
||
659 |
TInt CFreestyleMessageHeaderHTML::CalculateTotalSpaceRequired( const TDesC& aText, |
|
660 |
CFindItemEngine& aItemEngine, TInt& aMaxLength ) const |
|
661 |
{ |
|
662 |
TInt totalLength( 0 ); |
|
663 |
aMaxLength = KMinTInt; |
|
664 |
CFindItemEngine::SFoundItem item; |
|
665 |
aItemEngine.ResetPosition(); |
|
666 |
for ( TBool available( aItemEngine.Item( item ) ); available; available = aItemEngine.NextItem( item ) ) |
|
667 |
{ |
|
668 |
totalLength += item.iLength; |
|
669 |
if ( item.iItemType == CFindItemEngine::EFindItemSearchURLBin ) |
|
670 |
{ |
|
671 |
const TPtrC url( aText.Mid( item.iStartPos, item.iLength ) ); |
|
672 |
if ( url.FindF( KSchemeSeparator() ) == KErrNotFound ) |
|
673 |
{ |
|
674 |
totalLength += KUrlFormatWithHttp().Length(); |
|
675 |
} |
|
676 |
else |
|
677 |
{ |
|
678 |
totalLength += KUrlFormat().Length(); |
|
679 |
} |
|
680 |
aMaxLength = ( aMaxLength < item.iLength ) ? item.iLength : aMaxLength; |
|
681 |
} |
|
682 |
} |
|
683 |
aItemEngine.ResetPosition(); |
|
684 |
return totalLength; |
|
685 |
} |
|
686 |
||
687 |
HBufC* CFreestyleMessageHeaderHTML::CreateLinksLC( const TDesC& aText, const TInt aSearchCases ) const |
|
688 |
{ |
|
689 |
HBufC* result = NULL; |
|
690 |
CFindItemEngine* itemEngine = CFindItemEngine::NewL( aText, |
|
691 |
CFindItemEngine::TFindItemSearchCase( aSearchCases ) ); |
|
692 |
CleanupStack::PushL ( itemEngine ); |
|
693 |
if ( itemEngine->ItemCount() > 0 ) |
|
694 |
{ |
|
695 |
RBuf buf; |
|
696 |
TInt maxLength; |
|
697 |
buf.CreateL( CalculateTotalSpaceRequired( aText, *itemEngine, maxLength ) + aText.Length() ); |
|
698 |
buf.CleanupClosePushL(); |
|
699 |
TInt currentReadPosition( 0 ); |
|
700 |
CFindItemEngine::SFoundItem item; |
|
701 |
HBufC* urlBuffer = HBufC::NewLC( KUrlFormatWithHttp().Length() + maxLength * 2 ); |
|
702 |
for ( TBool available( itemEngine->Item( item ) ); available; available = itemEngine->NextItem( item ) ) |
|
703 |
{ |
|
704 |
// Append characters from currentReadPosition to iStartPos |
|
705 |
buf.Append( aText.Mid( currentReadPosition, item.iStartPos - currentReadPosition ) ); |
|
706 |
const TPtrC url( aText.Mid( item.iStartPos, item.iLength ) ); |
|
707 |
TPtrC format( KUrlFormat() ); |
|
708 |
if ( url.FindF( KSchemeSeparator() ) == KErrNotFound ) |
|
709 |
{ |
|
710 |
format.Set( KUrlFormatWithHttp() ); |
|
711 |
} |
|
712 |
urlBuffer->Des().Format( format, &url, &url ); |
|
713 |
buf.Append( *urlBuffer ); |
|
714 |
currentReadPosition = item.iStartPos + item.iLength; |
|
715 |
} |
|
716 |
CleanupStack::PopAndDestroy(); // urlBuffer |
|
717 |
// Append characters that are left in buffer |
|
718 |
buf.Append( aText.Mid( currentReadPosition ) ); |
|
719 |
result = buf.AllocL(); |
|
720 |
CleanupStack::PopAndDestroy(); // buf.Close() |
|
721 |
} |
|
722 |
else |
|
723 |
{ |
|
724 |
result = aText.AllocL(); |
|
725 |
} |
|
726 |
CleanupStack::PopAndDestroy( itemEngine ); |
|
727 |
CleanupStack::PushL( result ); |
|
728 |
return result; |
|
729 |
} |
|
730 |
||
731 |
void CFreestyleMessageHeaderHTML::ExportHTMLBodyEndL() const |
|
732 |
{ |
|
733 |
iWriteStream.WriteL( _L8("</body>\n</html>\n") ); |
|
734 |
iWriteStream.CommitL(); |
|
735 |
} |
|
736 |
||
737 |
void CFreestyleMessageHeaderHTML::ExportDisplayImagesTableL() const |
|
738 |
{ |
|
739 |
_LIT( KDisplayImagesLeftToRight, |
|
740 |
"<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\"><button value=\"submit\" class=\"submitBtn\" onClick=\"displayImagesButtonPressed()\"><span><span class=\"buttonText\">%S</span></span></button></td></tr></table>" ); |
|
741 |
||
742 |
_LIT( KDisplayImagesRightToLeft, |
|
743 |
"<script language=\"javascript\">var g_autoLoadImages = %d;</script><table style=\"display: none\" id=\"displayImagesTable\" width=\"%dpx\"><tr><td align=\"left\"><button value=\"submit\" class=\"submitBtn\" onClick=\"displayImagesButtonPressed()\"><span><span class=\"buttonText\">%S</span></span></button></td><td align=\"right\">%S</td></tr></table>" ); |
|
744 |
||
745 |
if ( iExportFlags.IsClear( EAutoLoadImages ) ) |
|
746 |
{ |
|
747 |
_LIT(KDescription, ""); |
|
748 |
HBufC* description = KDescription().AllocLC(); //StringLoader::LoadLC(R_FREESTYLE_EMAIL_UI_IMAGES_ARE_NOT_DISPLAYED); |
|
749 |
HBufC* button = StringLoader::LoadLC(R_FREESTYLE_EMAIL_UI_DISPLAY_IMAGES); |
|
750 |
HBufC* formatBuffer = NULL; |
|
751 |
if ( iExportFlags.IsSet( EMirroredLayout ) ) |
|
752 |
{ |
|
753 |
formatBuffer = HBufC::NewLC(KDisplayImagesRightToLeft().Length() + description->Length() + button->Length() + 8); |
|
754 |
formatBuffer->Des().Format( |
|
755 |
KDisplayImagesRightToLeft(), |
|
756 |
EFalse, |
|
757 |
iVisibleWidth, |
|
758 |
button, |
|
759 |
description); |
|
760 |
} |
|
761 |
else |
|
762 |
{ |
|
763 |
formatBuffer = HBufC::NewLC(KDisplayImagesLeftToRight().Length() + description->Length() + button->Length() + 8); |
|
764 |
formatBuffer->Des().Format( |
|
765 |
KDisplayImagesLeftToRight(), |
|
766 |
EFalse, |
|
767 |
iVisibleWidth, |
|
768 |
description, |
|
769 |
button); |
|
770 |
} |
|
771 |
HBufC8* utf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *formatBuffer ); |
|
772 |
CleanupStack::PushL( utf ); |
|
773 |
iWriteStream.WriteL( *utf ); |
|
774 |
CleanupStack::PopAndDestroy( 4 ); // description, button, formatBuffer, utf |
|
775 |
iWriteStream.CommitL(); |
|
776 |
} |
|
777 |
} |
|
778 |
||
779 |
void CFreestyleMessageHeaderHTML::ExportBodyStyleL() const |
|
780 |
{ |
|
781 |
iWriteStream.WriteL( _L8("<style type=\"text/css\">\n") ); |
|
782 |
#ifdef __USE_THEME_COLOR_FOR_HEADER |
|
783 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
784 |
TRgb textColor; |
|
785 |
TRgb bgColor; |
|
786 |
// Should use EAknsCIFsTextColorsCG3 if background is white |
|
787 |
if ( AknsUtils::GetCachedColor( skin, textColor, |
|
788 |
KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG81 ) != KErrNone || |
|
789 |
AknsUtils::GetCachedColor( skin, bgColor, |
|
790 |
KAknsIIDQsnOtherColors, EAknsCIQsnOtherColorsCG22 ) != KErrNone ) |
|
791 |
{ |
|
792 |
iWriteStream.WriteL( _L8("body { color: black; background-color: lightblue; }\n") ); |
|
793 |
} |
|
794 |
else |
|
795 |
{ |
|
796 |
// In future, query for which background color to use |
|
797 |
_LIT8( KBodyWithColor, "body { color: #%06x; background-color: #%06x; }\n" ); |
|
798 |
HBufC8* formatBuffer = HBufC8::NewLC(KBodyWithColor().Length() + 16); |
|
799 |
formatBuffer->Des().Format(KBodyWithColor(), textColor.Internal() & 0xFFFFFF, bgColor.Internal() & 0xFFFFFF); |
|
800 |
iWriteStream.WriteL( *formatBuffer ); |
|
801 |
CleanupStack::PopAndDestroy(); // formatBuffer |
|
802 |
} |
|
803 |
#else |
|
804 |
//iWriteStream.WriteL( _L8("body { color: black; background-color: lightblue; }\n") ); |
|
805 |
iWriteStream.WriteL( _L8("body { color: black; background-color: #c5c5c5; }\n") ); |
|
806 |
#endif // __USE_THEME_COLOR_FOR_HEADER |
|
807 |
iWriteStream.WriteL( _L8("</style>\n") ); |
|
808 |
iWriteStream.CommitL(); |
|
809 |
} |
|
810 |
||
811 |