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 70 | 968773a0b6ef |
permissions | -rw-r--r-- |
64 | 1 |
/* |
2 |
* Copyright (c) 2007 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: CFsEmailUiHtmlViewerContainer class implementation |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "emailtrace.h" |
|
20 |
#include <AknsDrawUtils.h> |
|
21 |
#include <coemain.h> |
|
22 |
#include <commdbconnpref.h> |
|
23 |
#include <bautils.h> |
|
24 |
#include <biditext.h> |
|
25 |
#include <StringLoader.h> |
|
26 |
#include <e32base.h> |
|
27 |
#include <badesca.h> |
|
28 |
#include <utf.h> |
|
29 |
#include <finditemengine.h> |
|
30 |
||
31 |
//<cmail> |
|
32 |
#include "cfsmailmessage.h" |
|
33 |
//</cmail> |
|
34 |
#include <brctlinterface.h> |
|
35 |
#include <sysutil.h> |
|
36 |
#include <schemehandler.h> |
|
37 |
||
38 |
#include <FreestyleEmailUi.rsg> |
|
39 |
||
40 |
#include "FreestyleEmailUiAppui.h" |
|
41 |
#include "FreestyleEmailUiUtilities.h" |
|
42 |
#include "FreestyleEmailUiHtmlViewerContainer.h" |
|
43 |
#include "FreestyleEmailUiHtmlViewerView.h" |
|
44 |
#include "FreestyleEmailUiShortcutBinding.h" |
|
45 |
||
46 |
#include "FreestyleMessageHeaderHTML.h" |
|
47 |
#include "FreestyleMessageHeaderURLEventHandler.h" |
|
48 |
#include "FreestyleEmailUiAttachmentsListModel.h" |
|
49 |
||
50 |
_LIT( KContentIdPrefix, "cid:" ); |
|
51 |
_LIT( KCDrive, "c:" ); |
|
52 |
_LIT( KHtmlPath, "HtmlFile\\" ); |
|
53 |
_LIT( KTempHtmlPath, "temp\\" ); |
|
54 |
_LIT( KAllFiles, "*" ); |
|
55 |
||
56 |
_LIT( KHeaderHtmlFile, "header.html" ); |
|
57 |
_LIT( KBodyHtmlFile, "body.html" ); |
|
58 |
_LIT( KMessageHtmlFile, "email.html" ); |
|
59 |
_LIT( KMessageHtmlRTLFile, "email_rtl.html" ); |
|
60 |
_LIT( KZDrive, "z:" ); |
|
61 |
_LIT( KHtmlFlagFile, "html.flag" ); |
|
62 |
_LIT( KURLSlash, "/"); |
|
63 |
// Constants used in html content modification |
|
64 |
const TInt KMaxCharsToSearch( 200 ); |
|
65 |
_LIT8( KStartTag, "<html" ); |
|
66 |
_LIT8( KHeadTag, "<head>"); |
|
67 |
_LIT8( KHtmlHeader1, "<html><head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset="); |
|
68 |
_LIT8( KHtmlHeader2, "\"/></head><body bgcolor=\"#ECECEC\">\xD\xA"); |
|
69 |
_LIT8( KHtmlHeader3, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%S\">\n"); |
|
70 |
_LIT8( KHtmlEndTags, "\xD\xA</body></html>\xD\xA"); |
|
71 |
_LIT8( KCharsetTag8, "charset"); |
|
72 |
_LIT( KCharsetTag, "charset"); |
|
73 |
_LIT8( KHTMLEmptyContent, "<html><body></body></html>"); |
|
74 |
_LIT( KHTMLDataScheme, "data:0"); |
|
75 |
||
76 |
||
77 |
_LIT( KHtmlLineBreak, "<br>" ); |
|
78 |
_LIT( KHtmlLineBreakCRLF, "<br>\xD\xA" ); |
|
79 |
_LIT( KHtmlLessThan, "<" ); |
|
80 |
_LIT( KHtmlGreaterThan, ">" ); |
|
81 |
_LIT( KHtmlAmpersand, "&" ); |
|
82 |
_LIT( KHtmlQuotation, """ ); |
|
83 |
_LIT( KURLTypeBody, "body"); |
|
84 |
||
85 |
_LIT( KURLDisplayImages, "cmail://displayImages/" ); |
|
86 |
_LIT( KURLLoadImages, "cmail://loadImages/" ); |
|
87 |
_LIT( KURLCollapseHeader, "cmail://collapseHeader/" ); |
|
88 |
_LIT( KURLExpandHeader, "cmail://expandHeader/" ); |
|
89 |
_LIT( KURLExpandItem, "cmail://expand_" ); |
|
90 |
_LIT( KURLItemTo, "to" ); |
|
91 |
_LIT( KURLItemCc, "cc" ); |
|
92 |
_LIT( KURLItemBcc, "bcc" ); |
|
93 |
_LIT( KURLItemAttachments, "attachments" ); |
|
94 |
||
95 |
const TText KGreaterThan = 0x3e; |
|
96 |
const TText KLessThan = 0x3c; |
|
97 |
const TText KAmpersand = 0x26; |
|
98 |
const TText KQuotation = 0x22; |
|
99 |
const TText KSOH = 0x01; // Start Of Heading |
|
100 |
const TText KLF = 0x0a; // Line Feed |
|
101 |
const TText KUnicodeNewLineCharacter = 0x2028; |
|
102 |
const TText KUnicodeParagraphCharacter = 0x2029; |
|
103 |
const TReal KOverlayButtonMarginX = 0.01; // 1% |
|
104 |
const TReal KOverlayButtonMarginY = 0.01; // 1% |
|
105 |
const TReal KOverlayButtonSizeP = 0.15; // 15% |
|
106 |
const TReal KOverlayButtonSizeLs = 0.20; // 25% |
|
107 |
||
108 |
||
109 |
const TInt KStatusIndicatorHeight = 55; |
|
110 |
const TInt KStatusIndicatorXMargin = 58; |
|
111 |
const TInt KStatusIndicatorBottomMargin = 6; |
|
112 |
||
113 |
// CONSTANTS |
|
114 |
// Zoom levels available on the UI |
|
115 |
const TInt KZoomLevels[] = { 75, 100, 125, 150 }; |
|
116 |
const TInt KZoomLevelCount = sizeof( KZoomLevels ) / sizeof( TInt ); |
|
117 |
const TInt KZoomLevelIndex100 = 1; // 100 in array KZoomLevels |
|
118 |
||
119 |
// CEUiHtmlViewerSettingsKeyListener |
|
120 |
||
121 |
// --------------------------------------------------------------------------- |
|
122 |
// |
|
123 |
// --------------------------------------------------------------------------- |
|
124 |
// |
|
125 |
CEUiHtmlViewerSettingsKeyListener::CEUiHtmlViewerSettingsKeyListener( MObserver& aObserver, TUint32 aKey ) |
|
126 |
: CActive( EPriorityStandard ), iObserver( aObserver ), iKey( aKey ) |
|
127 |
{ |
|
128 |
CActiveScheduler::Add(this); |
|
129 |
StartListening(); |
|
130 |
} |
|
131 |
||
132 |
// --------------------------------------------------------------------------- |
|
133 |
// |
|
134 |
// --------------------------------------------------------------------------- |
|
135 |
// |
|
136 |
CEUiHtmlViewerSettingsKeyListener::~CEUiHtmlViewerSettingsKeyListener() |
|
137 |
{ |
|
138 |
Cancel(); |
|
139 |
} |
|
140 |
||
141 |
// --------------------------------------------------------------------------- |
|
142 |
// |
|
143 |
// --------------------------------------------------------------------------- |
|
144 |
// |
|
145 |
void CEUiHtmlViewerSettingsKeyListener::StartListening() |
|
146 |
{ |
|
147 |
SetActive(); |
|
148 |
iObserver.Repository().NotifyRequest(iKey, iStatus); |
|
149 |
} |
|
150 |
||
151 |
// --------------------------------------------------------------------------- |
|
152 |
// |
|
153 |
// --------------------------------------------------------------------------- |
|
154 |
// |
|
155 |
void CEUiHtmlViewerSettingsKeyListener::RunL() |
|
156 |
{ |
|
157 |
iObserver.KeyValueChangedL(iKey); |
|
158 |
StartListening(); |
|
159 |
} |
|
160 |
||
161 |
// --------------------------------------------------------------------------- |
|
162 |
// |
|
163 |
// --------------------------------------------------------------------------- |
|
164 |
// |
|
165 |
void CEUiHtmlViewerSettingsKeyListener::DoCancel() |
|
166 |
{ |
|
167 |
iObserver.Repository().NotifyCancel(iKey); |
|
168 |
} |
|
169 |
||
170 |
// CEUiHtmlViewerSettings |
|
171 |
||
172 |
// --------------------------------------------------------------------------- |
|
173 |
// |
|
174 |
// --------------------------------------------------------------------------- |
|
175 |
// |
|
176 |
CEUiHtmlViewerSettings* CEUiHtmlViewerSettings::NewL( MObserver& aObserver ) |
|
177 |
{ |
|
178 |
CEUiHtmlViewerSettings* self = new (ELeave) CEUiHtmlViewerSettings(aObserver); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
179 |
CleanupStack::PushL(self); |
64 | 180 |
self->ConstructL(); |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
181 |
CleanupStack::Pop(); // self |
64 | 182 |
return self; |
183 |
} |
|
184 |
||
185 |
// --------------------------------------------------------------------------- |
|
186 |
// |
|
187 |
// --------------------------------------------------------------------------- |
|
188 |
// |
|
189 |
CEUiHtmlViewerSettings::~CEUiHtmlViewerSettings() |
|
190 |
{ |
|
191 |
iKeyListeners.ResetAndDestroy(); |
|
192 |
delete iRepository; |
|
193 |
} |
|
194 |
||
195 |
// --------------------------------------------------------------------------- |
|
196 |
// |
|
197 |
// --------------------------------------------------------------------------- |
|
198 |
// |
|
199 |
CEUiHtmlViewerSettings::CEUiHtmlViewerSettings( MObserver& aObserver ) : iObserver( aObserver ) |
|
200 |
{ |
|
201 |
} |
|
202 |
||
203 |
// --------------------------------------------------------------------------- |
|
204 |
// |
|
205 |
// --------------------------------------------------------------------------- |
|
206 |
// |
|
207 |
void CEUiHtmlViewerSettings::ConstructL() |
|
208 |
{ |
|
209 |
iRepository = CRepository::NewL(KFreestyleEmailCenRep); |
|
210 |
AddKeyListenerL(KFreestyleEmailDownloadHTMLImages); |
|
211 |
} |
|
212 |
||
213 |
// --------------------------------------------------------------------------- |
|
214 |
// |
|
215 |
// --------------------------------------------------------------------------- |
|
216 |
// |
|
217 |
void CEUiHtmlViewerSettings::AddKeyListenerL( TUint32 aKey ) |
|
218 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
219 |
CEUiHtmlViewerSettingsKeyListener* listener = new (ELeave) CEUiHtmlViewerSettingsKeyListener(*this, aKey); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
220 |
CleanupStack::PushL(listener); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
221 |
iKeyListeners.AppendL(listener); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
222 |
CleanupStack::Pop(); // listener |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
223 |
UpdateValue(aKey); |
64 | 224 |
} |
225 |
||
226 |
// --------------------------------------------------------------------------- |
|
227 |
// |
|
228 |
// --------------------------------------------------------------------------- |
|
229 |
// |
|
230 |
void CEUiHtmlViewerSettings::UpdateValue( TUint32 aKey ) |
|
231 |
{ |
|
232 |
TInt value; |
|
233 |
iRepository->Get(aKey, value); |
|
234 |
switch (aKey) |
|
235 |
{ |
|
236 |
case KFreestyleEmailDownloadHTMLImages: |
|
237 |
// 0 = automatic, 1 = ask always |
|
238 |
iFlags.Assign(aKey, value == 0); |
|
239 |
break; |
|
240 |
default: |
|
241 |
iFlags.Assign(aKey, value); |
|
242 |
break; |
|
243 |
} |
|
244 |
} |
|
245 |
||
246 |
// --------------------------------------------------------------------------- |
|
247 |
// |
|
248 |
// --------------------------------------------------------------------------- |
|
249 |
// |
|
250 |
void CEUiHtmlViewerSettings::KeyValueChangedL( TUint32 aKey ) |
|
251 |
{ |
|
252 |
UpdateValue(aKey); |
|
253 |
iObserver.ViewerSettingsChangedL(aKey); |
|
254 |
} |
|
255 |
||
256 |
// --------------------------------------------------------------------------- |
|
257 |
// |
|
258 |
// --------------------------------------------------------------------------- |
|
259 |
// |
|
260 |
CRepository& CEUiHtmlViewerSettings::Repository() |
|
261 |
{ |
|
262 |
return *iRepository; |
|
263 |
} |
|
264 |
||
265 |
// --------------------------------------------------------------------------- |
|
266 |
// |
|
267 |
// --------------------------------------------------------------------------- |
|
268 |
// |
|
269 |
TBool CEUiHtmlViewerSettings::AutoLoadImages() const |
|
270 |
{ |
|
271 |
return iFlags.IsSet(EAutoLoadImages); |
|
272 |
} |
|
273 |
||
274 |
// --------------------------------------------------------------------------- |
|
275 |
// Two-phased constructor. |
|
276 |
// --------------------------------------------------------------------------- |
|
277 |
// |
|
278 |
CFsEmailUiHtmlViewerContainer* CFsEmailUiHtmlViewerContainer::NewL( |
|
279 |
CFreestyleEmailUiAppUi& aAppUi, CFsEmailUiHtmlViewerView& aView ) |
|
280 |
{ |
|
281 |
FUNC_LOG; |
|
282 |
CFsEmailUiHtmlViewerContainer* self = |
|
283 |
new (ELeave) CFsEmailUiHtmlViewerContainer( aAppUi, aView ); |
|
284 |
CleanupStack::PushL( self ); |
|
285 |
self->ConstructL(); |
|
286 |
CleanupStack::Pop( self ); |
|
287 |
return self; |
|
288 |
} |
|
289 |
||
290 |
// --------------------------------------------------------------------------- |
|
291 |
// C++ constructor. |
|
292 |
// --------------------------------------------------------------------------- |
|
293 |
// |
|
294 |
CFsEmailUiHtmlViewerContainer::CFsEmailUiHtmlViewerContainer( |
|
295 |
CFreestyleEmailUiAppUi& aAppUi, CFsEmailUiHtmlViewerView& aView ) |
|
296 |
: |
|
297 |
iAppUi( aAppUi ), |
|
298 |
iView( aView ), |
|
299 |
iFs( iCoeEnv->FsSession() ), |
|
300 |
iFirstTime( ETrue ), |
|
301 |
iZoomLevel( KZoomLevelIndex100 ) |
|
302 |
{ |
|
303 |
FUNC_LOG; |
|
304 |
} |
|
305 |
||
306 |
// --------------------------------------------------------------------------- |
|
307 |
// Destructor. |
|
308 |
// --------------------------------------------------------------------------- |
|
309 |
// |
|
310 |
CFsEmailUiHtmlViewerContainer::~CFsEmailUiHtmlViewerContainer() |
|
311 |
{ |
|
312 |
FUNC_LOG; |
|
313 |
delete iViewerSettings; |
|
314 |
if ( iObservingDownload && iAppUi.DownloadInfoMediator() ) |
|
315 |
{ |
|
316 |
iAppUi.DownloadInfoMediator()->StopObserving( this ); |
|
317 |
} |
|
318 |
iFile.Close(); |
|
319 |
iLinkContents.Close(); |
|
320 |
iMessageParts.Close(); |
|
321 |
delete iEventHandler; |
|
322 |
delete iBrCtlInterface; |
|
323 |
iConnection.Close(); |
|
324 |
iSocketServer.Close(); |
|
325 |
delete iStatusIndicator; |
|
326 |
delete iOverlayControlNext; |
|
327 |
delete iOverlayControlPrev; |
|
328 |
} |
|
329 |
||
330 |
void CFsEmailUiHtmlViewerContainer::PrepareForExit() |
|
331 |
{ |
|
332 |
FUNC_LOG; |
|
333 |
HideDownloadStatus(); |
|
334 |
if ( iObservingDownload && iAppUi.DownloadInfoMediator() ) |
|
335 |
{ |
|
336 |
iAppUi.DownloadInfoMediator()->StopObserving( this ); |
|
337 |
iObservingDownload = EFalse; |
|
338 |
} |
|
339 |
delete iBrCtlInterface; |
|
340 |
iBrCtlInterface = NULL; |
|
341 |
iConnection.Close(); |
|
342 |
iSocketServer.Close(); |
|
343 |
} |
|
344 |
||
345 |
void CFsEmailUiHtmlViewerContainer::PrepareForMessageNavigation() |
|
346 |
{ |
|
347 |
FUNC_LOG; |
|
348 |
ResetContent(); |
|
349 |
} |
|
350 |
||
351 |
void CFsEmailUiHtmlViewerContainer::ZoomInL() |
|
352 |
{ |
|
353 |
SetZoomLevelL( ZoomLevelL() + 1 ); |
|
354 |
} |
|
355 |
||
356 |
void CFsEmailUiHtmlViewerContainer::ZoomOutL() |
|
357 |
{ |
|
358 |
SetZoomLevelL( ZoomLevelL() - 1 ); |
|
359 |
} |
|
360 |
||
361 |
TInt CFsEmailUiHtmlViewerContainer::ZoomLevelL() const |
|
362 |
{ |
|
363 |
FUNC_LOG; |
|
364 |
TInt zoomLevelIdx = iBrCtlInterface->BrowserSettingL( |
|
365 |
TBrCtlDefs::ESettingsCurrentZoomLevelIndex ); |
|
366 |
||
367 |
// Behaviour of zooming in Browser Control Interface is different in version 7.1 |
|
368 |
// than in previous versions and we need to support both. In older versions there |
|
369 |
// are 4 preset zoom levels while version 7.1 can zoom to any percent. |
|
370 |
RArray<TUint>* zoomLevels = iBrCtlInterface->ZoomLevels(); |
|
371 |
||
372 |
if ( !zoomLevels || !zoomLevels->Count() || ( *zoomLevels )[0] != KZoomLevels[0] ) |
|
373 |
{ |
|
374 |
// new browser: |
|
375 |
// BrowserControlIf gives zoom level percentage insted of index to array |
|
376 |
TBool found = EFalse; |
|
377 |
||
378 |
for ( TInt i = 0 ; i < KZoomLevelCount && !found ; ++i ) |
|
379 |
{ |
|
380 |
if ( zoomLevelIdx == KZoomLevels[i] ) |
|
381 |
{ |
|
382 |
zoomLevelIdx = i; |
|
383 |
found = ETrue; |
|
384 |
} |
|
385 |
} |
|
386 |
||
387 |
if ( !found ) |
|
388 |
{ |
|
389 |
zoomLevelIdx = KErrNotFound; |
|
390 |
} |
|
391 |
} |
|
392 |
return zoomLevelIdx; |
|
393 |
} |
|
394 |
||
395 |
void CFsEmailUiHtmlViewerContainer::SetZoomLevelL( const TInt aZoomLevel ) |
|
396 |
{ |
|
397 |
FUNC_LOG; |
|
398 |
TInt newValue = KMinTInt; |
|
399 |
||
400 |
// Behaviour of zooming in Browser Control Interface is different in version 7.1 |
|
401 |
// than in previous versions and we need to support both. In older versions there |
|
402 |
// are 4 preset zoom levels while version 7.1 can zoom to any percent. |
|
403 |
RArray<TUint>* zoomLevels = iBrCtlInterface->ZoomLevels(); |
|
404 |
||
405 |
if ( !zoomLevels || !zoomLevels->Count() || ( *zoomLevels )[0] != KZoomLevels[0] ) |
|
406 |
{ |
|
407 |
// new browser: |
|
408 |
// BrowserControlIf takes zoom level percentage insted of index to array |
|
409 |
if ( aZoomLevel >= 0 && aZoomLevel < KZoomLevelCount ) |
|
410 |
{ |
|
411 |
newValue = KZoomLevels[aZoomLevel]; |
|
412 |
} |
|
413 |
} |
|
414 |
else |
|
415 |
{ |
|
416 |
// old browser |
|
417 |
newValue = aZoomLevel; |
|
418 |
} |
|
419 |
||
420 |
iZoomLevel = ( newValue > KMinTInt ) ? newValue : aZoomLevel; |
|
421 |
iBrCtlInterface->SetBrowserSettingL( |
|
422 |
TBrCtlDefs::ESettingsCurrentZoomLevelIndex, iZoomLevel ); |
|
423 |
} |
|
424 |
||
425 |
TInt CFsEmailUiHtmlViewerContainer::DoZoom( TAny* aPtr ) |
|
426 |
{ |
|
427 |
TRAPD( error, reinterpret_cast<CFsEmailUiHtmlViewerContainer*>( aPtr )->DoZoomL() ); |
|
428 |
return error; |
|
429 |
} |
|
430 |
||
431 |
void CFsEmailUiHtmlViewerContainer::DoZoomL() |
|
432 |
{ |
|
433 |
iBrCtlInterface->SetBrowserSettingL( |
|
434 |
TBrCtlDefs::ESettingsCurrentZoomLevelIndex, iZoomLevel ); |
|
435 |
} |
|
436 |
||
437 |
TInt CFsEmailUiHtmlViewerContainer::MaxZoomLevel() const |
|
438 |
{ |
|
439 |
return KZoomLevelCount; |
|
440 |
} |
|
441 |
||
442 |
||
443 |
void CFsEmailUiHtmlViewerContainer::CreateBrowserControlInterfaceL() |
|
444 |
{ |
|
445 |
FUNC_LOG; |
|
446 |
||
447 |
if ( iBrCtlInterface ) |
|
448 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
449 |
delete iBrCtlInterface; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
450 |
iBrCtlInterface = NULL; |
64 | 451 |
} |
452 |
||
453 |
TUint brCtlCapabilities = TBrCtlDefs::ECapabilityClientResolveEmbeddedURL | |
|
454 |
TBrCtlDefs::ECapabilityDisplayScrollBar | |
|
455 |
TBrCtlDefs::ECapabilityClientNotifyURL | |
|
456 |
TBrCtlDefs::ECapabilityLoadHttpFw | |
|
457 |
TBrCtlDefs::ECapabilityCursorNavigation | |
|
458 |
TBrCtlDefs::ECapabilityPinchZoom | |
|
459 |
TBrCtlDefs::ECapabilityFitToScreen; |
|
460 |
||
461 |
// Set browsercontrol to whole screen |
|
462 |
TRect rect( TPoint(), Size() ); |
|
463 |
||
464 |
iBrCtlInterface = CreateBrowserControlL( |
|
465 |
this, // aParent |
|
466 |
rect, // aRect |
|
467 |
brCtlCapabilities, // aBrCtlCapabilities |
|
468 |
TBrCtlDefs::ECommandIdBase, // aCommandIdBase |
|
469 |
NULL, // aBrCtlSoftkeysObserver |
|
470 |
this, // aBrCtlLinkResolver |
|
471 |
this, // aBrCtlSpecialLoadObserver |
|
472 |
NULL, // aBrCtlLayoutObserver |
|
473 |
NULL, // aBrCtlDialogsProvider |
|
474 |
this, // aBrCtlWindowObserver |
|
475 |
NULL // aBrCtlDownloadObserver |
|
476 |
); |
|
477 |
||
478 |
iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsEmbedded, ETrue ); |
|
479 |
iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsAutoLoadImages, iViewerSettings->AutoLoadImages() ); |
|
480 |
iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsPageOverview, EFalse ); |
|
481 |
iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsTextWrapEnabled, ETrue ); |
|
482 |
iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsFontSize, TBrCtlDefs::EFontSizeLevelLarger ); |
|
483 |
} |
|
484 |
||
485 |
void CFsEmailUiHtmlViewerContainer::ConstructL() |
|
486 |
{ |
|
487 |
FUNC_LOG; |
|
488 |
iViewerSettings = CEUiHtmlViewerSettings::NewL(*this); |
|
489 |
||
490 |
SetHtmlFolderPathL(); |
|
491 |
BaflUtils::EnsurePathExistsL( iFs, iHtmlFolderPath ); |
|
492 |
SetTempHtmlFolderPath(); |
|
493 |
BaflUtils::EnsurePathExistsL( iFs, iTempHtmlFolderPath ); |
|
494 |
SetHTMLResourceFlagFullName(); |
|
495 |
EnsureHTMLResourceL(); |
|
496 |
||
497 |
CreateWindowL(); |
|
498 |
||
499 |
#if defined( BRDO_MULTITOUCH_ENABLED_FF ) && !defined ( __WINSCW__ ) |
|
500 |
//Enable advance pointer info for multi-touch. |
|
501 |
Window().EnableAdvancedPointers(); |
|
502 |
#endif |
|
503 |
||
504 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
505 |
SetRect( iView.ContainerRect() ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
506 |
CreateBrowserControlInterfaceL(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
507 |
|
64 | 508 |
iEventHandler = CFreestyleMessageHeaderURLEventHandler::NewL( iAppUi, iView ); |
509 |
||
510 |
TRect nextButtonRect = OverlayButtonRect( EFalse ); |
|
511 |
iOverlayControlNext = COverlayControl::NewL( this, this, nextButtonRect, |
|
512 |
EMbmFreestyleemailuiQgn_indi_cmail_arrow_next, |
|
513 |
EMbmFreestyleemailuiQgn_indi_cmail_arrow_next_mask ); |
|
514 |
||
515 |
TRect prevButtonRect = OverlayButtonRect( ETrue ); |
|
516 |
iOverlayControlPrev = COverlayControl::NewL( this, this, prevButtonRect, |
|
517 |
EMbmFreestyleemailuiQgn_indi_cmail_arrow_previous, |
|
518 |
EMbmFreestyleemailuiQgn_indi_cmail_arrow_previous_mask ); |
|
519 |
iScrollPosition = 0; |
|
520 |
iAttachmentDownloadImageHandle = 0; |
|
521 |
||
522 |
iTouchFeedBack = MTouchFeedback::Instance(); |
|
523 |
iTouchFeedBack->EnableFeedbackForControl(this, ETrue); |
|
524 |
||
525 |
ActivateL(); |
|
526 |
} |
|
527 |
||
528 |
void CFsEmailUiHtmlViewerContainer::MakeVisible( TBool aVisible ) |
|
529 |
{ |
|
530 |
UpdateOverlayButtons( aVisible ); |
|
531 |
CCoeControl::MakeVisible( aVisible ); |
|
532 |
} |
|
533 |
||
534 |
void CFsEmailUiHtmlViewerContainer::HandleOverlayPointerEventL( COverlayControl* aControl, |
|
535 |
const TPointerEvent& aEvent ) |
|
536 |
{ |
|
537 |
if( aEvent.iType == TPointerEvent::EButton1Up ) |
|
538 |
{ |
|
539 |
if( aControl == iOverlayControlNext ) |
|
540 |
{ |
|
541 |
iView.HandleCommandL( EFsEmailUiCmdNextMessage ); |
|
542 |
} |
|
543 |
else if( aControl == iOverlayControlPrev ) |
|
544 |
{ |
|
545 |
iView.HandleCommandL( EFsEmailUiCmdPreviousMessage ); |
|
546 |
} |
|
547 |
} |
|
548 |
} |
|
549 |
||
550 |
void CFsEmailUiHtmlViewerContainer::UpdateOverlayButtons( TBool aVisible ) |
|
551 |
{ |
|
552 |
TBool nextAvailable = EFalse; |
|
553 |
TBool prevAvailable = EFalse; |
|
554 |
if( iMessage ) |
|
555 |
{ |
|
556 |
TFSMailMsgId currentMsgId = iMessage->GetMessageId(); |
|
557 |
TFSMailMsgId tmpMsgId; |
|
558 |
TFSMailMsgId tmpMsgFolderId; |
|
559 |
nextAvailable = iAppUi.IsNextMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ); |
|
560 |
prevAvailable = iAppUi.IsPreviousMsgAvailable( currentMsgId, tmpMsgId, tmpMsgFolderId ); |
|
561 |
} |
|
562 |
||
563 |
if( iOverlayControlPrev ) |
|
564 |
{ |
|
565 |
iOverlayControlPrev->SetRect( OverlayButtonRect( ETrue ) ); |
|
566 |
iOverlayControlPrev->MakeVisible( aVisible && prevAvailable ); |
|
567 |
} |
|
568 |
if( iOverlayControlNext ) |
|
569 |
{ |
|
570 |
iOverlayControlNext->SetRect( OverlayButtonRect( EFalse ) ); |
|
571 |
iOverlayControlNext->MakeVisible( aVisible && nextAvailable ); |
|
572 |
} |
|
573 |
} |
|
574 |
||
575 |
// Get rect for button |
|
576 |
TRect CFsEmailUiHtmlViewerContainer::OverlayButtonRect( TBool aLeft ) |
|
577 |
{ |
|
578 |
TRect rect = Rect(); |
|
579 |
TSize size = rect.Size(); |
|
580 |
||
581 |
TBool landscape = size.iWidth > size.iHeight; |
|
582 |
TInt buttonSize; |
|
583 |
||
584 |
if( landscape ) |
|
585 |
{ |
|
586 |
buttonSize = size.iHeight * KOverlayButtonSizeLs; |
|
587 |
} |
|
588 |
else |
|
589 |
{ |
|
590 |
buttonSize = size.iWidth * KOverlayButtonSizeP; |
|
591 |
} |
|
592 |
||
593 |
rect.iBr.iY = size.iHeight * (1-KOverlayButtonMarginY); |
|
594 |
||
595 |
if( aLeft ) |
|
596 |
{ |
|
597 |
rect.iTl.iX = size.iWidth * KOverlayButtonMarginX; |
|
598 |
rect.iBr.iX = rect.iTl.iX + buttonSize; |
|
599 |
} |
|
600 |
else |
|
601 |
{ |
|
602 |
rect.iBr.iX = size.iWidth * (1 - KOverlayButtonMarginX); |
|
603 |
rect.iTl.iX = rect.iBr.iX - buttonSize; |
|
604 |
} |
|
605 |
||
606 |
rect.iTl.iY = rect.iBr.iY - buttonSize; |
|
607 |
return rect; |
|
608 |
} |
|
609 |
||
610 |
// Getter for br contro, interface |
|
611 |
CBrCtlInterface* CFsEmailUiHtmlViewerContainer::BrowserControlIf() |
|
612 |
{ |
|
613 |
FUNC_LOG; |
|
614 |
return iBrCtlInterface; |
|
615 |
} |
|
616 |
||
617 |
void CFsEmailUiHtmlViewerContainer::LoadContentFromFileL( const TDesC& aFileName ) |
|
618 |
{ |
|
619 |
FUNC_LOG; |
|
620 |
iBrCtlInterface->LoadFileL( aFileName ); |
|
621 |
} |
|
622 |
||
623 |
void CFsEmailUiHtmlViewerContainer::LoadContentFromFileL( RFile& aFile ) |
|
624 |
{ |
|
625 |
FUNC_LOG; |
|
626 |
iBrCtlInterface->LoadFileL( aFile ); |
|
627 |
} |
|
628 |
||
629 |
void CFsEmailUiHtmlViewerContainer::LoadContentFromUrlL( const TDesC& aUrl ) |
|
630 |
{ |
|
631 |
FUNC_LOG; |
|
632 |
iBrCtlInterface->LoadUrlL( aUrl ); |
|
633 |
} |
|
634 |
||
635 |
// --------------------------------------------------------------------------- |
|
636 |
// Loads content from given mail message. |
|
637 |
// --------------------------------------------------------------------------- |
|
638 |
// |
|
639 |
void CFsEmailUiHtmlViewerContainer::LoadContentFromMailMessageL( |
|
640 |
CFSMailMessage* aMailMessage, TBool aResetScrollPos ) |
|
641 |
{ |
|
642 |
FUNC_LOG; |
|
643 |
ASSERT( aMailMessage ); |
|
644 |
iMessage = aMailMessage; |
|
645 |
// Cancel any browser fetch operation, just in case the browser is still |
|
646 |
// loading a previous message (since we are about to overwrite it). |
|
647 |
CancelFetch(); |
|
648 |
||
649 |
TPath headerHtmlFile; |
|
650 |
headerHtmlFile.Copy( iHtmlFolderPath ); |
|
651 |
headerHtmlFile.Append( KHeaderHtmlFile ); |
|
652 |
||
653 |
// insert email header into email.html file |
|
654 |
// CFreestyleMessageHeaderHTML will replace contents of email.html |
|
655 |
// So, no need to clear the contents |
|
656 |
if(aResetScrollPos) |
|
657 |
{ |
|
658 |
iScrollPosition = 0; |
|
659 |
} |
|
660 |
const TInt visibleWidth(iAppUi.ClientRect().Width()); |
|
661 |
CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, visibleWidth, iScrollPosition, |
|
662 |
iViewerSettings->AutoLoadImages() || iAppUi.DisplayImagesCache().Contains(*iMessage), iFlags ); |
|
663 |
||
664 |
// Remove all previously created files from temporary HTML folder |
|
665 |
EmptyTempHtmlFolderL(); |
|
666 |
||
667 |
TRAPD( error, PrepareBodyHtmlL( KBodyHtmlFile ) ); |
|
668 |
if ( error != KErrNone ) |
|
669 |
{ |
|
670 |
WriteEmptyBodyHtmlL( KBodyHtmlFile ); |
|
671 |
} |
|
672 |
||
673 |
// pass the emailHtmlFile to the browser for it to load |
|
674 |
TPath emailHtmlFile; |
|
675 |
emailHtmlFile.Copy( iHtmlFolderPath ); |
|
676 |
if ( !AknLayoutUtils::LayoutMirrored() ) |
|
677 |
{ |
|
678 |
emailHtmlFile.Append( KMessageHtmlFile ); |
|
679 |
} |
|
680 |
else |
|
681 |
{ |
|
682 |
emailHtmlFile.Append( KMessageHtmlRTLFile ); |
|
683 |
} |
|
684 |
||
685 |
// If scroll position is not to be reset, re-creation of browser control |
|
686 |
// interface object is skipped (we're just reloading the page with new |
|
687 |
// content) |
|
688 |
if ( aResetScrollPos ) |
|
689 |
{ |
|
690 |
CreateBrowserControlInterfaceL(); |
|
691 |
} |
|
692 |
||
693 |
LoadContentFromFileL( emailHtmlFile ); |
|
694 |
||
695 |
UpdateOverlayButtons( ETrue ); |
|
696 |
} |
|
697 |
||
698 |
// --------------------------------------------------------------------------- |
|
699 |
// Reset content |
|
700 |
// --------------------------------------------------------------------------- |
|
701 |
// |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
702 |
void CFsEmailUiHtmlViewerContainer::ResetContent(const TBool aDisconnect) |
64 | 703 |
{ |
704 |
FUNC_LOG; |
|
705 |
if ( iBrCtlInterface ) |
|
706 |
{ |
|
707 |
TRAP_IGNORE( |
|
708 |
iBrCtlInterface->HandleCommandL( ( TInt )TBrCtlDefs::ECommandIdBase + |
|
709 |
( TInt )TBrCtlDefs::ECommandFreeMemory ) ); |
|
710 |
if (aDisconnect) |
|
711 |
{ |
|
712 |
TRAP_IGNORE( |
|
713 |
iBrCtlInterface->HandleCommandL( ( TInt )TBrCtlDefs::ECommandIdBase + |
|
714 |
( TInt )TBrCtlDefs::ECommandDisconnect ) ); |
|
715 |
} |
|
716 |
} |
|
717 |
iFile.Close(); |
|
718 |
iLinkContents.Reset(); |
|
719 |
iMessageParts.Reset(); |
|
720 |
iMessage = NULL; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
721 |
iFlags.ClearAll(); |
64 | 722 |
iScrollPosition = 0; |
723 |
} |
|
724 |
||
725 |
// --------------------------------------------------------------------------- |
|
726 |
// From CCoeControl. |
|
727 |
// --------------------------------------------------------------------------- |
|
728 |
// |
|
729 |
CCoeControl* CFsEmailUiHtmlViewerContainer::ComponentControl( TInt aIndex ) const |
|
730 |
{ |
|
731 |
FUNC_LOG; |
|
732 |
switch ( aIndex ) |
|
733 |
{ |
|
734 |
case 0: |
|
735 |
{ |
|
736 |
return iBrCtlInterface; |
|
737 |
} |
|
738 |
case 1: |
|
739 |
{ |
|
740 |
return iOverlayControlNext; |
|
741 |
} |
|
742 |
case 2: |
|
743 |
{ |
|
744 |
return iOverlayControlPrev; |
|
745 |
} |
|
746 |
case 3: |
|
747 |
{ |
|
748 |
if ( iStatusIndicator ) |
|
749 |
return iStatusIndicator; |
|
750 |
else |
|
751 |
return NULL; |
|
752 |
} |
|
753 |
default: |
|
754 |
{ |
|
755 |
return NULL; |
|
756 |
} |
|
757 |
} |
|
758 |
} |
|
759 |
||
760 |
// --------------------------------------------------------------------------- |
|
761 |
// From CCoeControl. |
|
762 |
// --------------------------------------------------------------------------- |
|
763 |
// |
|
764 |
TInt CFsEmailUiHtmlViewerContainer::CountComponentControls() const |
|
765 |
{ |
|
766 |
FUNC_LOG; |
|
767 |
if ( iStatusIndicator ) |
|
768 |
{ |
|
769 |
return 4; |
|
770 |
} |
|
771 |
else |
|
772 |
{ |
|
773 |
return 3; |
|
774 |
} |
|
775 |
} |
|
776 |
||
777 |
// --------------------------------------------------------------------------- |
|
778 |
// From CCoeControl. |
|
779 |
// Draw this application's view to the screen |
|
780 |
// --------------------------------------------------------------------------- |
|
781 |
// |
|
782 |
void CFsEmailUiHtmlViewerContainer::Draw( const TRect& /*aRect*/ ) const |
|
783 |
{ |
|
784 |
FUNC_LOG; |
|
785 |
// Get the standard graphics context |
|
786 |
CWindowGc& gc = SystemGc(); |
|
787 |
||
788 |
// Gets the control's extent |
|
789 |
TRect rect = Rect(); |
|
790 |
||
791 |
// Clears the screen |
|
792 |
gc.Clear( rect ); |
|
793 |
} |
|
794 |
||
795 |
// --------------------------------------------------------------------------- |
|
796 |
// From CCoeControl. |
|
797 |
// --------------------------------------------------------------------------- |
|
798 |
// |
|
799 |
void CFsEmailUiHtmlViewerContainer::SizeChanged() |
|
800 |
{ |
|
801 |
FUNC_LOG; |
|
802 |
||
803 |
TRect rect = Rect(); |
|
804 |
if ( iBrCtlInterface ) |
|
805 |
{ |
|
806 |
iBrCtlInterface->SetRect( rect ); |
|
807 |
} |
|
808 |
||
809 |
UpdateOverlayButtons( IsVisible() ); |
|
810 |
||
811 |
if ( iStatusIndicator ) |
|
812 |
{ |
|
813 |
TRect rect = CalcAttachmentStatusRect(); |
|
814 |
iStatusIndicator->SetRect( rect ); |
|
815 |
} |
|
816 |
} |
|
817 |
||
818 |
// --------------------------------------------------------------------------- |
|
819 |
// From CCoeControl. |
|
820 |
// --------------------------------------------------------------------------- |
|
821 |
// |
|
822 |
TKeyResponse CFsEmailUiHtmlViewerContainer::OfferKeyEventL( |
|
823 |
const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
824 |
{ |
|
825 |
FUNC_LOG; |
|
826 |
||
827 |
TKeyResponse retVal = EKeyWasNotConsumed; |
|
828 |
||
829 |
// Handle keyboard shortcuts already on key down event as all keys |
|
830 |
// do not necessarily send the key event at all. |
|
831 |
if ( aType == EEventKeyDown ) |
|
832 |
{ |
|
833 |
// Check keyboard shortcuts |
|
834 |
TInt shortcutCommand = iAppUi.ShortcutBinding().CommandForShortcutKey( |
|
835 |
aKeyEvent, CFSEmailUiShortcutBinding::EContextHtmlViewer ); |
|
836 |
||
837 |
if ( shortcutCommand != KErrNotFound ) |
|
838 |
{ |
|
839 |
iView.HandleCommandL( shortcutCommand ); |
|
840 |
retVal = EKeyWasConsumed; |
|
841 |
} |
|
842 |
} |
|
843 |
||
844 |
if ( iBrCtlInterface && retVal == EKeyWasNotConsumed ) |
|
845 |
{ |
|
846 |
TKeyEvent event = aKeyEvent; |
|
847 |
if ( iBrCtlInterface->FocusedElementType() == TBrCtlDefs::EElementButton |
|
848 |
&& ( aKeyEvent.iScanCode == EStdKeyNkpEnter |
|
849 |
|| aKeyEvent.iScanCode == EStdKeyEnter ) ) |
|
850 |
{ |
|
851 |
// Enter key events are converted to selection key event in |
|
852 |
// order to get browser to handle them in similar way. |
|
853 |
event.iScanCode = EStdKeyDevice3; |
|
854 |
event.iCode = aKeyEvent.iCode ? EKeyDevice3 : 0; |
|
855 |
} |
|
856 |
retVal = iBrCtlInterface->OfferKeyEventL( event, aType ); |
|
857 |
} |
|
858 |
||
859 |
iView.SetMskL(); |
|
860 |
||
861 |
return retVal; |
|
862 |
} |
|
863 |
||
864 |
// --------------------------------------------------------------------------- |
|
865 |
// From MBrCtlSpecialLoadObserver. |
|
866 |
// --------------------------------------------------------------------------- |
|
867 |
// |
|
868 |
void CFsEmailUiHtmlViewerContainer::NetworkConnectionNeededL( |
|
869 |
TInt* aConnectionPtr, |
|
870 |
TInt* aSockSvrHandle, |
|
871 |
TBool* aNewConn, |
|
872 |
TApBearerType* aBearerType ) |
|
873 |
{ |
|
874 |
FUNC_LOG; |
|
875 |
*aBearerType = EApBearerTypeAllBearers; |
|
876 |
||
877 |
if ( iFirstTime ) |
|
878 |
{ |
|
879 |
User::LeaveIfError( iSocketServer.Connect( KESockDefaultMessageSlots ) ); |
|
880 |
User::LeaveIfError( iConnection.Open( iSocketServer, KConnectionTypeDefault ) ); |
|
881 |
TCommDbConnPref prefs; |
|
882 |
prefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); |
|
883 |
prefs.SetDirection( ECommDbConnectionDirectionOutgoing ); |
|
884 |
prefs.SetIapId( 0 ); // Ask for access point |
|
885 |
User::LeaveIfError( iConnection.Start( prefs ) ); |
|
886 |
*aNewConn = ETrue; |
|
887 |
iFirstTime = EFalse; |
|
888 |
} |
|
889 |
else |
|
890 |
{ |
|
891 |
*aNewConn = EFalse; |
|
892 |
} |
|
893 |
||
894 |
*aConnectionPtr = reinterpret_cast<TInt>(&iConnection); |
|
895 |
*aSockSvrHandle = iSocketServer.Handle(); |
|
896 |
} |
|
897 |
||
898 |
// --------------------------------------------------------------------------- |
|
899 |
// From MBrCtlSpecialLoadObserver. |
|
900 |
// --------------------------------------------------------------------------- |
|
901 |
// |
|
902 |
TBool CFsEmailUiHtmlViewerContainer::HandleRequestL( |
|
903 |
RArray<TUint>* /*aTypeArray*/, CDesCArrayFlat* /*aDesArray*/ ) |
|
904 |
{ |
|
905 |
FUNC_LOG; |
|
906 |
// Let browser control handle these |
|
907 |
return EFalse; |
|
908 |
} |
|
909 |
||
910 |
// --------------------------------------------------------------------------- |
|
911 |
// From MBrCtlSpecialLoadObserver. |
|
912 |
// --------------------------------------------------------------------------- |
|
913 |
// |
|
914 |
TBool CFsEmailUiHtmlViewerContainer::HandleDownloadL( |
|
915 |
RArray<TUint>* /*aTypeArray*/, CDesCArrayFlat* /*aDesArray*/ ) |
|
916 |
{ |
|
917 |
FUNC_LOG; |
|
918 |
// Let browser control handle these |
|
919 |
return EFalse; |
|
920 |
} |
|
921 |
||
922 |
// --------------------------------------------------------------------------- |
|
923 |
// From MFSEmailDownloadInformationObserver. |
|
924 |
// --------------------------------------------------------------------------- |
|
925 |
// |
|
926 |
void CFsEmailUiHtmlViewerContainer::RequestResponseL( const TFSProgress& aEvent, |
|
927 |
const TPartData& aPart ) |
|
928 |
{ |
|
929 |
FUNC_LOG; |
|
930 |
if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete ) |
|
931 |
{ |
|
932 |
MBrCtlLinkContent* linkContent = NULL; |
|
933 |
for ( TInt ii = iMessageParts.Count() - 1; ii >= 0 && !linkContent; --ii ) |
|
934 |
{ |
|
935 |
if ( iMessageParts[ii] == aPart ) |
|
936 |
{ |
|
937 |
iMessageParts.Remove( ii ); |
|
938 |
linkContent = iLinkContents[ii]; |
|
939 |
iLinkContents.Remove( ii ); |
|
940 |
} |
|
941 |
} |
|
942 |
||
943 |
if ( !iMessageParts.Count() && iAppUi.DownloadInfoMediator() ) |
|
944 |
{ |
|
945 |
iAppUi.DownloadInfoMediator()->StopObserving( this ); |
|
946 |
} |
|
947 |
||
948 |
if ( iMessage && linkContent ) |
|
949 |
{ |
|
950 |
CFSMailMessagePart* part = iMessage->ChildPartL( aPart.iMessagePartId ); |
|
951 |
CleanupStack::PushL( part ); |
|
952 |
RFile contentFile = part->GetContentFileL(); |
|
953 |
CleanupClosePushL( contentFile ); |
|
954 |
HBufC8* content = ReadContentFromFileLC( contentFile, *part ); |
|
955 |
linkContent->HandleResolveComplete( |
|
956 |
part->GetContentType(), KNullDesC(), content ); |
|
957 |
CleanupStack::PopAndDestroy( content ); |
|
958 |
CleanupStack::PopAndDestroy( &contentFile ); |
|
959 |
CleanupStack::PopAndDestroy( part ); |
|
960 |
} |
|
961 |
||
962 |
if ( iMessage ) |
|
963 |
{ |
|
964 |
LoadContentFromMailMessageL( iMessage, EFalse ); |
|
965 |
UpdateOverlayButtons( ETrue ); |
|
966 |
} |
|
967 |
} |
|
968 |
else if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled || |
|
969 |
aEvent.iProgressStatus < 0 ) |
|
970 |
{ |
|
971 |
if ( iAppUi.DownloadInfoMediator() ) |
|
972 |
{ |
|
973 |
iAppUi.DownloadInfoMediator()->StopObserving( this, aPart.iMessageId ); |
|
974 |
} |
|
975 |
} |
|
976 |
} |
|
977 |
||
978 |
// --------------------------------------------------------------------------- |
|
979 |
// From MBrCtlLinkResolver. |
|
980 |
// --------------------------------------------------------------------------- |
|
981 |
// |
|
982 |
TBool CFsEmailUiHtmlViewerContainer::ResolveEmbeddedLinkL( |
|
983 |
const TDesC& aEmbeddedUrl, const TDesC& /*aCurrentUrl*/, |
|
984 |
TBrCtlLoadContentType /*aLoadContentType*/, |
|
985 |
MBrCtlLinkContent& aEmbeddedLinkContent ) |
|
986 |
{ |
|
987 |
FUNC_LOG; |
|
988 |
TBool linkResolved = EFalse; |
|
989 |
||
990 |
// Check if given link contains content ID |
|
991 |
if ( aEmbeddedUrl.Left( KContentIdPrefix().Length() ).CompareF( KContentIdPrefix ) == 0 ) |
|
992 |
{ |
|
993 |
TPtrC cid = aEmbeddedUrl.Mid( KContentIdPrefix().Length() ); |
|
994 |
linkResolved = ResolveLinkL( cid, ETrue, aEmbeddedLinkContent ); |
|
995 |
} |
|
996 |
else |
|
997 |
{ |
|
998 |
// Replace all slash character with backslash characters |
|
999 |
HBufC* embeddedUrl = aEmbeddedUrl.AllocLC(); |
|
1000 |
TPtr ptr = embeddedUrl->Des(); |
|
1001 |
_LIT( KBackslash, "\\" ); |
|
1002 |
for ( TInt pos = ptr.Locate('/'); pos >= 0; pos = ptr.Locate('/') ) |
|
1003 |
{ |
|
1004 |
ptr.Replace( pos, 1, KBackslash ); |
|
1005 |
} |
|
1006 |
||
1007 |
// Check whether given url refers to file in the temporary html folder |
|
1008 |
TInt pos = embeddedUrl->FindF( iTempHtmlFolderPath ); |
|
1009 |
if ( pos >= 0 ) |
|
1010 |
{ |
|
1011 |
TPtrC filename = embeddedUrl->Mid( pos + iTempHtmlFolderPath.Length() ); |
|
1012 |
linkResolved = ResolveLinkL( filename, EFalse, aEmbeddedLinkContent ); |
|
1013 |
} |
|
1014 |
||
1015 |
CleanupStack::PopAndDestroy( embeddedUrl ); |
|
1016 |
} |
|
1017 |
||
1018 |
// Return whether link is resolved by host application. |
|
1019 |
return linkResolved; |
|
1020 |
} |
|
1021 |
||
1022 |
// --------------------------------------------------------------------------- |
|
1023 |
// From MBrCtlLinkResolver. |
|
1024 |
// --------------------------------------------------------------------------- |
|
1025 |
// |
|
1026 |
TBool CFsEmailUiHtmlViewerContainer::ResolveLinkL( const TDesC& aUrl, |
|
1027 |
const TDesC& /*aCurrentUrl*/, MBrCtlLinkContent& /*aBrCtlLinkContent*/ ) |
|
1028 |
{ |
|
1029 |
FUNC_LOG; |
|
1030 |
if ( IsMessageBodyURLL(aUrl) ) |
|
1031 |
{ |
|
1032 |
if ( iMessage ) |
|
1033 |
{ |
|
1034 |
iView.StartFetchingMessageL(); |
|
1035 |
} |
|
1036 |
return ETrue; |
|
1037 |
} |
|
1038 |
else |
|
1039 |
{ |
|
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1040 |
// special handling for such file links that for which corresponding |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1041 |
// file is not found in local disk. We try to modify such links to |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1042 |
// have http prefix so that browser could open them as they're likely |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1043 |
// <href=www...> type tags (i.e., tags missing the scheme) which the |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1044 |
// browser control has interpreted as local files |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1045 |
HBufC* modifiedUrl = CreateModifiedUrlIfNeededL( aUrl ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1046 |
if ( modifiedUrl ) |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1047 |
{ |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1048 |
TBool rVal( ETrue ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1049 |
CleanupStack::PushL( modifiedUrl ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1050 |
rVal = iEventHandler->HandleEventL( *modifiedUrl ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1051 |
CleanupStack::PopAndDestroy( modifiedUrl ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1052 |
return rVal; |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1053 |
} |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1054 |
|
64 | 1055 |
if ( NeedToLaunchBrowserL( aUrl ) ) |
1056 |
{ |
|
1057 |
LaunchBrowserL( aUrl ); |
|
1058 |
return ETrue; |
|
1059 |
} |
|
1060 |
else |
|
1061 |
{ |
|
1062 |
return iEventHandler->HandleEventL( aUrl ); |
|
1063 |
} |
|
1064 |
} |
|
1065 |
} |
|
1066 |
||
1067 |
// --------------------------------------------------------------------------- |
|
1068 |
// From MBrCtlLinkResolver. |
|
1069 |
// --------------------------------------------------------------------------- |
|
1070 |
// |
|
1071 |
void CFsEmailUiHtmlViewerContainer::CancelAll() |
|
1072 |
{ |
|
1073 |
FUNC_LOG; |
|
1074 |
} |
|
1075 |
||
1076 |
// --------------------------------------------------------------------------- |
|
1077 |
// From MBrCtlSoftkeysObserver |
|
1078 |
// --------------------------------------------------------------------------- |
|
1079 |
// |
|
1080 |
void CFsEmailUiHtmlViewerContainer::UpdateSoftkeyL( |
|
1081 |
TBrCtlKeySoftkey /*aKeySoftkey*/, const TDesC& /*aLabel*/, |
|
1082 |
TUint32 /*aCommandId*/, |
|
1083 |
TBrCtlSoftkeyChangeReason /*aBrCtlSoftkeyChangeReason*/ ) |
|
1084 |
{ |
|
1085 |
FUNC_LOG; |
|
1086 |
} |
|
1087 |
||
1088 |
// --------------------------------------------------------------------------- |
|
1089 |
// Set HTML folder path name |
|
1090 |
// --------------------------------------------------------------------------- |
|
1091 |
// |
|
1092 |
void CFsEmailUiHtmlViewerContainer::SetHtmlFolderPathL() |
|
1093 |
{ |
|
1094 |
FUNC_LOG; |
|
1095 |
iHtmlFolderPath.Copy( KCDrive ); |
|
1096 |
||
1097 |
TFileName privatePath; |
|
1098 |
User::LeaveIfError( iFs.PrivatePath( privatePath ) ); |
|
1099 |
iHtmlFolderPath.Append( privatePath ); |
|
1100 |
||
1101 |
iHtmlFolderPath.Append( KHtmlPath ); |
|
1102 |
} |
|
1103 |
||
1104 |
// --------------------------------------------------------------------------- |
|
1105 |
// Sets temporary HTML folder path name |
|
1106 |
// --------------------------------------------------------------------------- |
|
1107 |
// |
|
1108 |
void CFsEmailUiHtmlViewerContainer::SetTempHtmlFolderPath() |
|
1109 |
{ |
|
1110 |
FUNC_LOG; |
|
1111 |
iTempHtmlFolderPath.Copy( iHtmlFolderPath ); |
|
1112 |
iTempHtmlFolderPath.Append( KTempHtmlPath ); |
|
1113 |
} |
|
1114 |
||
1115 |
// --------------------------------------------------------------------------- |
|
1116 |
// Remove all previously created files from temporary HTML folder |
|
1117 |
// --------------------------------------------------------------------------- |
|
1118 |
// |
|
1119 |
void CFsEmailUiHtmlViewerContainer::EmptyTempHtmlFolderL() |
|
1120 |
{ |
|
1121 |
FUNC_LOG; |
|
1122 |
// Delete all files from temp folder |
|
1123 |
TFileName allFiles; |
|
1124 |
allFiles.Append( iTempHtmlFolderPath ); |
|
1125 |
allFiles.Append( KAllFiles ); |
|
1126 |
TInt err = BaflUtils::DeleteFile( iFs, allFiles ); |
|
1127 |
if ( err != KErrNotFound && err != KErrNone ) |
|
1128 |
{ |
|
1129 |
User::LeaveIfError( err ); |
|
1130 |
} |
|
1131 |
} |
|
1132 |
||
1133 |
// --------------------------------------------------------------------------- |
|
1134 |
// Copies given read-only file to HTML file |
|
1135 |
// --------------------------------------------------------------------------- |
|
1136 |
// |
|
1137 |
// <cmail> |
|
1138 |
void CFsEmailUiHtmlViewerContainer::CopyToHtmlFileL( CFSMailMessagePart& aHtmlBodyPart, const TDesC& aFileName ) |
|
1139 |
{ |
|
1140 |
FUNC_LOG; |
|
1141 |
TFileName targetFileName; |
|
1142 |
targetFileName.Copy( iTempHtmlFolderPath ); |
|
1143 |
targetFileName.Append( aFileName ); |
|
1144 |
||
1145 |
RFile htmlFile = aHtmlBodyPart.GetContentFileL(); |
|
1146 |
CleanupClosePushL( htmlFile ); |
|
1147 |
||
1148 |
// Read content from given source file |
|
1149 |
HBufC8* content = ReadContentFromFileLC( htmlFile, aHtmlBodyPart ); |
|
1150 |
||
1151 |
// Write content to target file |
|
1152 |
WriteContentToFileL( *content, targetFileName, aHtmlBodyPart ); |
|
1153 |
||
1154 |
CleanupStack::PopAndDestroy( content ); |
|
1155 |
CleanupStack::PopAndDestroy( &htmlFile ); |
|
1156 |
} |
|
1157 |
// </cmail> |
|
1158 |
||
1159 |
// --------------------------------------------------------------------------- |
|
1160 |
// Copies given buffer to HTML file |
|
1161 |
// --------------------------------------------------------------------------- |
|
1162 |
// |
|
1163 |
// <cmail> |
|
1164 |
void CFsEmailUiHtmlViewerContainer::ConvertToHtmlFileL( CFSMailMessagePart& aTextBodyPart, const TDesC& aHtmlFileName ) |
|
1165 |
{ |
|
1166 |
FUNC_LOG; |
|
1167 |
TFileName targetFileName; |
|
1168 |
targetFileName.Copy( iTempHtmlFolderPath ); |
|
1169 |
targetFileName.Append( aHtmlFileName ); |
|
1170 |
||
1171 |
TInt contentsize = aTextBodyPart.FetchedContentSize(); |
|
1172 |
||
1173 |
TInt limit(0); |
|
1174 |
TInt err = iViewerSettings->Repository().Get( KFreestyleMaxBodySize , limit ); |
|
1175 |
limit *= KKilo; // cenrep value is in kB, 0 means unlimited |
|
1176 |
||
1177 |
if ( limit == 0 || err ) |
|
1178 |
{ |
|
1179 |
limit = KMaxTInt; |
|
1180 |
} |
|
1181 |
||
1182 |
TInt size = Min(limit,contentsize); |
|
1183 |
HBufC* content = HBufC::NewLC( size ); |
|
1184 |
TPtr contentPtr( content->Des() ); |
|
1185 |
||
1186 |
aTextBodyPart.GetContentToBufferL( contentPtr, 0 ); |
|
1187 |
//When we found EFSMsgFlag_BodyTruncated was set, add "--Message too long--" in the end of plain html view |
|
1188 |
if ( limit < contentsize ) |
|
1189 |
{ |
|
1190 |
// Disable this is PS1 until we have translations available |
|
1191 |
// HBufC* addingText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEW_ADDITIONAL_INFO , limit/KKilo ); |
|
1192 |
// TInt pos = contentPtr.Length() - addingText->Length(); |
|
1193 |
// contentPtr.Replace(pos,addingText->Length(),*addingText); |
|
1194 |
// CleanupStack::PopAndDestroy( addingText ); |
|
1195 |
aTextBodyPart.SetFlag(EFSMsgFlag_BodyTruncated); |
|
1196 |
} |
|
1197 |
||
1198 |
ConvertToHTML( *content, targetFileName, aTextBodyPart ); |
|
1199 |
CleanupStack::PopAndDestroy( content ); |
|
1200 |
} |
|
1201 |
||
1202 |
// --------------------------------------------------------------------------- |
|
1203 |
// Reads given file content to buffer and return pointer to it |
|
1204 |
// --------------------------------------------------------------------------- |
|
1205 |
// |
|
1206 |
HBufC8* CFsEmailUiHtmlViewerContainer::ReadContentFromFileLC( RFile& aFile, |
|
1207 |
CFSMailMessagePart& aBodyPart ) |
|
1208 |
{ |
|
1209 |
FUNC_LOG; |
|
1210 |
TInt fileSize = 0; |
|
1211 |
User::LeaveIfError( aFile.Size( fileSize ) ); |
|
1212 |
||
1213 |
HBufC* contentType = aBodyPart.GetContentType().AllocLC(); |
|
1214 |
TInt length = contentType->Locate(';'); |
|
1215 |
if( length >= 0 ) |
|
1216 |
{ |
|
1217 |
contentType->Des().SetLength( length ); |
|
1218 |
} |
|
1219 |
TBool body = KFSMailContentTypeTextPlain().CompareF( contentType->Des() ) == 0 || |
|
1220 |
KFSMailContentTypeTextHtml().CompareF( contentType->Des() ) == 0; |
|
1221 |
CleanupStack::PopAndDestroy( contentType ); |
|
1222 |
||
1223 |
if ( body ) |
|
1224 |
{ |
|
1225 |
// limit message size if not done already by plugins |
|
1226 |
TInt limit(0); |
|
1227 |
TInt err = iViewerSettings->Repository().Get( KFreestyleMaxBodySize , limit ); |
|
1228 |
limit *= KKilo; // cenrep value is in kB, 0 means unlimited |
|
1229 |
||
1230 |
if ( limit == 0 || err ) |
|
1231 |
{ |
|
1232 |
limit = KMaxTInt; |
|
1233 |
} |
|
1234 |
fileSize = Min( limit, fileSize ); // read no more than limit bytes.. |
|
1235 |
||
1236 |
TInt contentSize = aBodyPart.ContentSize(); |
|
1237 |
TInt fetchedSize = aBodyPart.FetchedContentSize(); |
|
1238 |
||
1239 |
if ( ( limit!=KMaxTInt && fileSize < contentSize ) |
|
1240 |
|| ( fetchedSize < contentSize ) ) |
|
1241 |
{ |
|
1242 |
aBodyPart.SetFlag( EFSMsgFlag_BodyTruncated ); |
|
1243 |
} |
|
1244 |
} |
|
1245 |
HBufC8* buffer = HBufC8::NewLC( fileSize ); |
|
1246 |
TPtr8 ptr = buffer->Des(); |
|
1247 |
User::LeaveIfError( aFile.Read( ptr, fileSize ) ); |
|
1248 |
return buffer; |
|
1249 |
} |
|
1250 |
||
1251 |
// --------------------------------------------------------------------------- |
|
1252 |
// Writes buffer content to given file |
|
1253 |
// --------------------------------------------------------------------------- |
|
1254 |
// |
|
1255 |
// <cmail> |
|
1256 |
void CFsEmailUiHtmlViewerContainer::WriteContentToFileL( const TDesC8& aContent, |
|
1257 |
const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart ) |
|
1258 |
{ |
|
1259 |
FUNC_LOG; |
|
1260 |
||
1261 |
RBuf8 buffer; |
|
1262 |
buffer.CreateL( aContent ); |
|
1263 |
buffer.CleanupClosePushL(); |
|
1264 |
||
1265 |
if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, buffer.Size(), EDriveC ) ) |
|
1266 |
{ |
|
1267 |
// Can not write the data, there's not enough free space on disk. |
|
1268 |
User::Leave( KErrDiskFull ); |
|
1269 |
} |
|
1270 |
else |
|
1271 |
{ |
|
1272 |
RFile targetFile; |
|
1273 |
CleanupClosePushL( targetFile ); |
|
1274 |
||
1275 |
User::LeaveIfError( targetFile.Replace( iFs, aFileName, EFileWrite ) ); |
|
1276 |
||
1277 |
// Try to find initial html tag (both '<html' and '<HTML' versions are searched) |
|
1278 |
TInt startTagOffset = buffer.Left( KMaxCharsToSearch ).FindF( KStartTag ); |
|
1279 |
||
1280 |
// Modifying text/html atta IF there's no '<html>' tag anywhere in |
|
1281 |
// the begining of file (KMaxCharsToSearch) AND there is charset |
|
1282 |
// parameter available |
|
1283 |
TBool modificationNeeded( EFalse ); |
|
1284 |
if( startTagOffset == KErrNotFound ) |
|
1285 |
{ |
|
1286 |
modificationNeeded = ETrue; |
|
1287 |
} |
|
1288 |
||
1289 |
// Write starting metadata if needed |
|
1290 |
if ( modificationNeeded ) |
|
1291 |
{ |
|
1292 |
HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart ); |
|
1293 |
CleanupStack::PushL( charSet ); |
|
1294 |
||
1295 |
User::LeaveIfError( targetFile.Write( KHtmlHeader1 ) ); |
|
1296 |
User::LeaveIfError( targetFile.Write( *charSet ) ); |
|
1297 |
User::LeaveIfError( targetFile.Write( KHtmlHeader2 ) ); |
|
1298 |
CleanupStack::PopAndDestroy( charSet ); |
|
1299 |
} |
|
1300 |
else |
|
1301 |
{ |
|
1302 |
// Charset tag not found in html body |
|
1303 |
||
1304 |
if ( buffer.Left( KMaxCharsToSearch ).FindF( KCharsetTag8 ) == KErrNotFound ) |
|
1305 |
{ |
|
1306 |
TInt startPos(0); |
|
1307 |
if ( ( startPos = buffer.Left( KMaxCharsToSearch ).FindF( KHeadTag ) ) != KErrNotFound ) |
|
1308 |
{ |
|
1309 |
||
1310 |
HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart ); |
|
1311 |
CleanupStack::PushL( charSet ); |
|
1312 |
||
1313 |
HBufC8* metaBuffer = HBufC8::NewLC( charSet->Des().Length() + KHtmlHeader3().Length() ); |
|
1314 |
TPtr8 metaHeader( metaBuffer->Des() ); |
|
1315 |
metaHeader.AppendFormat( KHtmlHeader3, charSet ); |
|
1316 |
TInt maxLength = buffer.Length() + metaHeader.Length(); |
|
1317 |
buffer.ReAllocL( maxLength ); |
|
1318 |
||
1319 |
startPos += KHeadTag().Length(); |
|
1320 |
buffer.Insert( startPos, metaHeader ); |
|
1321 |
||
1322 |
CleanupStack::PopAndDestroy( metaBuffer ); |
|
1323 |
CleanupStack::PopAndDestroy( charSet ); |
|
1324 |
} |
|
1325 |
} |
|
1326 |
} |
|
1327 |
||
1328 |
// Write the original content |
|
1329 |
User::LeaveIfError( targetFile.Write( buffer ) ); |
|
1330 |
if( aHtmlBodyPart.GetFlags() & EFSMsgFlag_BodyTruncated ) |
|
1331 |
{ |
|
1332 |
//When we found EFSMsgFlag_BodyTruncated was set, add "--- Message limited to %N kB ---" in the end of html view |
|
1333 |
TInt limit(0); |
|
1334 |
TInt err = iViewerSettings->Repository().Get( KFreestyleMaxBodySize , limit ); |
|
1335 |
limit *= KKilo; // cenrep value is in kB, 0 means unlimited |
|
1336 |
if ( limit == 0 || err ) |
|
1337 |
{ |
|
1338 |
limit = KMaxTInt; |
|
1339 |
} |
|
1340 |
||
1341 |
// Disable this is PS1 until we have translations available |
|
1342 |
// HBufC* addingText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEW_ADDITIONAL_INFO, limit/KKilo ); |
|
1343 |
// HBufC8* addingText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *addingText ); |
|
1344 |
// CleanupStack::PopAndDestroy( addingText ); |
|
1345 |
// CleanupStack::PushL( addingText8 ); |
|
1346 |
// User::LeaveIfError( targetFile.Write( *addingText8 ) ); |
|
1347 |
// CleanupStack::PopAndDestroy( addingText8 ); |
|
1348 |
} |
|
1349 |
// Write ending metadata if needed |
|
1350 |
if ( modificationNeeded || (aHtmlBodyPart.GetFlags()&EFSMsgFlag_BodyTruncated) ) |
|
1351 |
{ |
|
1352 |
INFO("Add end tags"); |
|
1353 |
User::LeaveIfError( targetFile.Write( KHtmlEndTags ) ); |
|
1354 |
} |
|
1355 |
||
1356 |
CleanupStack::PopAndDestroy( &targetFile ); |
|
1357 |
} |
|
1358 |
CleanupStack::PopAndDestroy( &buffer ); |
|
1359 |
// </cmail> |
|
1360 |
} |
|
1361 |
||
1362 |
// --------------------------------------------------------------------------- |
|
1363 |
// Finds the attachment from the list that matches the given content ID |
|
1364 |
// --------------------------------------------------------------------------- |
|
1365 |
// |
|
1366 |
CFSMailMessagePart* CFsEmailUiHtmlViewerContainer::MatchingAttacmentL( |
|
1367 |
const TDesC& aContentId, |
|
1368 |
const RPointerArray<CFSMailMessagePart>& aAttachments ) const |
|
1369 |
{ |
|
1370 |
FUNC_LOG; |
|
1371 |
TBool contentFound = EFalse; |
|
1372 |
CFSMailMessagePart* attachment = NULL; |
|
1373 |
TInt attachmentCount = aAttachments.Count(); |
|
1374 |
||
1375 |
// Check whether one of the attachments has the given conten ID |
|
1376 |
for ( TInt i = 0; i < attachmentCount && !contentFound; i++ ) |
|
1377 |
{ |
|
1378 |
attachment = aAttachments[i]; |
|
1379 |
const TDesC& contentId = attachment->ContentID(); |
|
1380 |
if ( contentId.Compare( aContentId ) == 0 ) |
|
1381 |
{ |
|
1382 |
contentFound = ETrue; |
|
1383 |
} |
|
1384 |
} |
|
1385 |
||
1386 |
// If attacment with given content ID was not found, check whether |
|
1387 |
// the given content ID contains the name of one of the attachments |
|
1388 |
for ( TInt i = 0; i < attachmentCount && !contentFound; ++i ) |
|
1389 |
{ |
|
1390 |
attachment = aAttachments[i]; |
|
1391 |
const TDesC& name = attachment->AttachmentNameL(); |
|
1392 |
if ( aContentId.FindF( name ) >= 0 ) |
|
1393 |
{ |
|
1394 |
contentFound = ETrue; |
|
1395 |
} |
|
1396 |
} |
|
1397 |
||
1398 |
if ( !contentFound ) |
|
1399 |
{ |
|
1400 |
attachment = NULL; |
|
1401 |
} |
|
1402 |
return attachment; |
|
1403 |
} |
|
1404 |
||
1405 |
// --------------------------------------------------------------------------- |
|
1406 |
// Resolves link referring to file in temporary HTML folder |
|
1407 |
// --------------------------------------------------------------------------- |
|
1408 |
// |
|
1409 |
TBool CFsEmailUiHtmlViewerContainer::ResolveLinkL( const TDesC& aLink, |
|
1410 |
TBool aContentId, MBrCtlLinkContent& aEmbeddedLinkContent ) |
|
1411 |
{ |
|
1412 |
FUNC_LOG; |
|
1413 |
TBool linkResolved = EFalse; |
|
1414 |
CFSMailMessagePart* attachment = NULL; |
|
1415 |
||
1416 |
RPointerArray<CFSMailMessagePart> attachments; |
|
1417 |
CleanupResetAndDestroyClosePushL( attachments ); |
|
1418 |
iMessage->AttachmentListL( attachments ); |
|
1419 |
||
1420 |
if ( aContentId ) |
|
1421 |
{ |
|
1422 |
attachment = MatchingAttacmentL( aLink, attachments ); |
|
1423 |
} |
|
1424 |
else |
|
1425 |
{ |
|
1426 |
const TInt attachmentCount = attachments.Count(); |
|
1427 |
for ( TInt ii = 0; ii < attachmentCount && !attachment; ++ii ) |
|
1428 |
{ |
|
1429 |
if ( aLink.CompareF( attachments[ii]->AttachmentNameL() ) == 0 ) |
|
1430 |
{ |
|
1431 |
attachment = attachments[ii]; |
|
1432 |
} |
|
1433 |
} |
|
1434 |
} |
|
1435 |
||
1436 |
if ( attachment ) |
|
1437 |
{ |
|
1438 |
DownloadAttachmentL( *attachment, aEmbeddedLinkContent ); |
|
1439 |
linkResolved = ETrue; |
|
1440 |
} |
|
1441 |
||
1442 |
CleanupStack::PopAndDestroy( &attachments ); |
|
1443 |
return linkResolved; |
|
1444 |
} |
|
1445 |
||
1446 |
// --------------------------------------------------------------------------- |
|
1447 |
// Download attachment and return the content via MBrCtlLinkContent interface |
|
1448 |
// --------------------------------------------------------------------------- |
|
1449 |
// |
|
1450 |
void CFsEmailUiHtmlViewerContainer::DownloadAttachmentL( |
|
1451 |
CFSMailMessagePart& aAttachment, MBrCtlLinkContent& aEmbeddedLinkContent ) |
|
1452 |
{ |
|
1453 |
FUNC_LOG; |
|
1454 |
if ( aAttachment.FetchLoadState() == EFSFull ) |
|
1455 |
{ |
|
1456 |
RFile attachmentFile = aAttachment.GetContentFileL(); |
|
1457 |
CleanupClosePushL( attachmentFile ); |
|
1458 |
HBufC8* content = ReadContentFromFileLC( attachmentFile, aAttachment ); |
|
1459 |
aEmbeddedLinkContent.HandleResolveComplete( |
|
1460 |
aAttachment.GetContentType(), KNullDesC(), content ); |
|
1461 |
CleanupStack::PopAndDestroy( content ); |
|
1462 |
CleanupStack::PopAndDestroy( &attachmentFile ); |
|
1463 |
} |
|
1464 |
else |
|
1465 |
{ |
|
1466 |
TPartData partData; |
|
1467 |
if( iMessage ) |
|
1468 |
{ |
|
1469 |
partData.iMailBoxId = iMessage->GetMailBoxId(); |
|
1470 |
partData.iFolderId = iMessage->GetFolderId(); |
|
1471 |
partData.iMessageId = iMessage->GetMessageId(); |
|
1472 |
||
1473 |
partData.iMessagePartId = aAttachment.GetPartId(); |
|
1474 |
||
1475 |
if ( iAppUi.DownloadInfoMediator() && |
|
1476 |
iAppUi.DownloadInfoMediator()->IsDownloadableL( partData ) ) |
|
1477 |
{ |
|
1478 |
ASSERT( iLinkContents.Count() == iMessageParts.Count() ); |
|
1479 |
||
1480 |
// Append message part details and embedded link content interface |
|
1481 |
// to corresponding arrays so that the content can be returned |
|
1482 |
// when the download is completed. |
|
1483 |
iLinkContents.AppendL( &aEmbeddedLinkContent ); |
|
1484 |
if ( iMessageParts.Append( partData ) != KErrNone ) |
|
1485 |
{ |
|
1486 |
iLinkContents.Remove( iLinkContents.Count() - 1 ); |
|
1487 |
} |
|
1488 |
||
1489 |
ASSERT( iLinkContents.Count() == iMessageParts.Count() ); |
|
1490 |
if(!iView.GetAsyncFetchStatus()) |
|
1491 |
{ |
|
1492 |
iAppUi.DownloadInfoMediator()->AddObserver( this, aAttachment.GetMessageId() ); |
|
1493 |
iObservingDownload=ETrue; |
|
1494 |
iAppUi.DownloadInfoMediator()->DownloadL( partData, EFalse ); |
|
1495 |
} |
|
1496 |
} |
|
1497 |
} |
|
1498 |
} |
|
1499 |
} |
|
1500 |
||
1501 |
void CFsEmailUiHtmlViewerContainer::SetHTMLResourceFlagFullName() |
|
1502 |
{ |
|
1503 |
FUNC_LOG; |
|
1504 |
iHtmlResourceFlagPath.Copy( iHtmlFolderPath ); |
|
1505 |
iHtmlResourceFlagPath.Append( KHtmlFlagFile ); |
|
1506 |
} |
|
1507 |
||
1508 |
void CFsEmailUiHtmlViewerContainer::EnableHTMLResourceFlagL() |
|
1509 |
{ |
|
1510 |
FUNC_LOG; |
|
1511 |
RFile flag; |
|
1512 |
User::LeaveIfError( flag.Replace(iFs, iHtmlResourceFlagPath, EFileWrite) ); |
|
1513 |
flag.Close(); |
|
1514 |
} |
|
1515 |
||
1516 |
TBool CFsEmailUiHtmlViewerContainer::HTMLResourceFlagEnabled() |
|
1517 |
{ |
|
1518 |
FUNC_LOG; |
|
1519 |
return BaflUtils::FileExists( iFs, iHtmlResourceFlagPath ); |
|
1520 |
} |
|
1521 |
||
1522 |
void CFsEmailUiHtmlViewerContainer::CopyHTMLResourceL() |
|
1523 |
{ |
|
1524 |
FUNC_LOG; |
|
1525 |
||
1526 |
TPath htmlFolderPathInZ; |
|
1527 |
htmlFolderPathInZ.Copy( KZDrive ); |
|
1528 |
||
1529 |
TFileName privatePath; |
|
1530 |
User::LeaveIfError( iFs.PrivatePath( privatePath ) ); |
|
1531 |
htmlFolderPathInZ.Append( privatePath ); |
|
1532 |
||
1533 |
htmlFolderPathInZ.Append( KHtmlPath ); |
|
1534 |
||
1535 |
CDir* dirList; |
|
1536 |
TPath listSpec; |
|
1537 |
listSpec.Copy( htmlFolderPathInZ ); |
|
1538 |
||
1539 |
listSpec.Append( _L("*.*") ); |
|
1540 |
User::LeaveIfError( iFs.GetDir( listSpec, KEntryAttMaskSupported, ESortByName, dirList ) ); |
|
1541 |
CleanupStack::PushL( dirList ); |
|
1542 |
for ( TInt i=0; i < dirList->Count(); i++) |
|
1543 |
{ |
|
1544 |
TPath sourceFileFullName; |
|
1545 |
sourceFileFullName.Copy( htmlFolderPathInZ ); |
|
1546 |
sourceFileFullName.Append( (*dirList)[i].iName ); |
|
1547 |
||
1548 |
TBool isFolder( EFalse ); |
|
1549 |
BaflUtils::IsFolder( iFs, sourceFileFullName, isFolder); |
|
1550 |
if ( isFolder ) |
|
1551 |
{ |
|
1552 |
break; |
|
1553 |
} |
|
1554 |
||
1555 |
TPath targetFileFullName; |
|
1556 |
targetFileFullName.Copy( iHtmlFolderPath ); |
|
1557 |
targetFileFullName.Append( (*dirList)[i].iName ); |
|
1558 |
BaflUtils::DeleteFile( iFs, targetFileFullName ); |
|
1559 |
||
1560 |
BaflUtils::CopyFile( iFs, sourceFileFullName, targetFileFullName); |
|
1561 |
} |
|
1562 |
CleanupStack::PopAndDestroy( dirList ); |
|
1563 |
} |
|
1564 |
||
1565 |
void CFsEmailUiHtmlViewerContainer::EnsureHTMLResourceL() |
|
1566 |
{ |
|
1567 |
FUNC_LOG; |
|
1568 |
||
1569 |
if ( !HTMLResourceFlagEnabled() ) |
|
1570 |
{ |
|
1571 |
CopyHTMLResourceL(); |
|
1572 |
EnableHTMLResourceFlagL(); |
|
1573 |
} |
|
1574 |
} |
|
1575 |
||
1576 |
// --------------------------------------------------------------------------- |
|
1577 |
// Writes buffer content to given file after adding tags |
|
1578 |
// --------------------------------------------------------------------------- |
|
1579 |
// |
|
1580 |
void CFsEmailUiHtmlViewerContainer::ConvertToHTML( const TDesC& aContent, |
|
1581 |
const TDesC& aFileName, CFSMailMessagePart& /*aTextBodyPart*/ ) |
|
1582 |
{ |
|
1583 |
FUNC_LOG; |
|
1584 |
||
1585 |
if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, aContent.Size(), EDriveC ) ) |
|
1586 |
{ |
|
1587 |
// Can not write the data, there's not enough free space on disk. |
|
1588 |
User::Leave( KErrDiskFull ); |
|
1589 |
} |
|
1590 |
||
1591 |
RBuf htmlText; |
|
1592 |
CleanupClosePushL( htmlText ); |
|
1593 |
||
1594 |
PlainTextToHtmlConverter::PlainTextToHtmlL( aContent, htmlText ); |
|
1595 |
WriteToFileL( aFileName, htmlText ); |
|
1596 |
||
1597 |
CleanupStack::PopAndDestroy( &htmlText ); |
|
1598 |
} |
|
1599 |
||
1600 |
||
1601 |
TInt CFsEmailUiHtmlViewerContainer::TotalLengthOfItems( CFindItemEngine& aItemEngine ) const |
|
1602 |
{ |
|
1603 |
TInt totalLength( 0 ); |
|
1604 |
CFindItemEngine::SFoundItem item; |
|
1605 |
aItemEngine.ResetPosition(); |
|
1606 |
for ( TBool available( aItemEngine.Item( item ) ); available; available = aItemEngine.NextItem( item ) ) |
|
1607 |
{ |
|
1608 |
totalLength += item.iLength; |
|
1609 |
} |
|
1610 |
aItemEngine.ResetPosition(); |
|
1611 |
return totalLength; |
|
1612 |
} |
|
1613 |
||
1614 |
// --------------------------------------------------------------------------- |
|
1615 |
// Get Character set from CFSMailMessagePart |
|
1616 |
// --------------------------------------------------------------------------- |
|
1617 |
// |
|
1618 |
// <cmail> |
|
1619 |
HBufC8* CFsEmailUiHtmlViewerContainer::GetCharacterSetL( CFSMailMessagePart& aHtmlBodyPart ) |
|
1620 |
{ |
|
1621 |
FUNC_LOG; |
|
1622 |
||
1623 |
CDesCArray& contentTypeArray( aHtmlBodyPart.ContentTypeParameters() ); |
|
1624 |
HBufC8* charSet = KNullDesC8().AllocLC(); |
|
1625 |
||
1626 |
for ( TInt i = 0; i < contentTypeArray.Count(); i++ ) |
|
1627 |
{ |
|
1628 |
TPtrC contentEntry( contentTypeArray.MdcaPoint( i ) ); |
|
1629 |
if ( ( contentEntry.FindF( KCharsetTag ) != KErrNotFound ) && |
|
1630 |
contentTypeArray.Count() >= ( i+1) ) |
|
1631 |
{ |
|
1632 |
TPtrC value( contentTypeArray.MdcaPoint( i+1 ) ); |
|
1633 |
if ( value.Length() ) |
|
1634 |
{ |
|
1635 |
CleanupStack::PopAndDestroy( charSet ); |
|
1636 |
charSet = NULL; |
|
1637 |
charSet = HBufC8::NewLC( value.Length() ); |
|
1638 |
charSet->Des().Copy( value ); |
|
1639 |
break; |
|
1640 |
} |
|
1641 |
} |
|
1642 |
i++; |
|
1643 |
} |
|
1644 |
||
1645 |
CleanupStack::Pop( charSet ); |
|
1646 |
return charSet; |
|
1647 |
} |
|
1648 |
||
1649 |
void CFsEmailUiHtmlViewerContainer::StopObserving() |
|
1650 |
{ |
|
1651 |
if( iObservingDownload ) |
|
1652 |
{ |
|
1653 |
if ( iMessage && iAppUi.DownloadInfoMediator() ) |
|
1654 |
{ |
|
1655 |
iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() ); |
|
1656 |
} |
|
1657 |
iObservingDownload=EFalse; |
|
1658 |
} |
|
1659 |
} |
|
1660 |
||
1661 |
void CFsEmailUiHtmlViewerContainer::CancelFetch() |
|
1662 |
{ |
|
1663 |
FUNC_LOG; |
|
1664 |
if ( iBrCtlInterface ) |
|
1665 |
{ |
|
1666 |
TRAP_IGNORE( iBrCtlInterface->HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase )); |
|
1667 |
} |
|
1668 |
} |
|
1669 |
||
1670 |
void CFsEmailUiHtmlViewerContainer::ClearCacheAndLoadEmptyContent() |
|
1671 |
{ |
|
1672 |
FUNC_LOG; |
|
1673 |
if ( iBrCtlInterface ) |
|
1674 |
{ |
|
1675 |
iBrCtlInterface->ClearCache(); |
|
1676 |
TUid uid; |
|
1677 |
uid.iUid = KCharacterSetIdentifierUtf8; |
|
1678 |
TRAP_IGNORE( iBrCtlInterface->LoadDataL(KHTMLDataScheme, KHTMLEmptyContent, _L8("text/html"), uid) ); |
|
1679 |
} |
|
1680 |
} |
|
1681 |
||
1682 |
void CFsEmailUiHtmlViewerContainer::HandleResourceChange( TInt aType ) |
|
1683 |
{ |
|
1684 |
CCoeControl::HandleResourceChange( aType ); |
|
1685 |
if ( aType == CFsEmailUiViewBase::EScreenLayoutChanged ) |
|
1686 |
{ |
|
1687 |
RefreshCurrentMailHeader(); |
|
1688 |
SetRect( iView.ContainerRect() ); |
|
1689 |
} |
|
1690 |
} |
|
1691 |
||
1692 |
void CFsEmailUiHtmlViewerContainer::RefreshCurrentMailHeader() |
|
1693 |
{ |
|
1694 |
if ( iMessage ) |
|
1695 |
{ |
|
1696 |
// Update the width in header part and reload |
|
1697 |
TPath headerHtmlFile; |
|
1698 |
headerHtmlFile.Copy( iHtmlFolderPath ); |
|
1699 |
headerHtmlFile.Append( KHeaderHtmlFile ); |
|
1700 |
||
1701 |
TRAP_IGNORE( CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, |
|
1702 |
headerHtmlFile, iAppUi.ClientRect().Width(), iScrollPosition, |
|
1703 |
iViewerSettings->AutoLoadImages() || iAppUi.DisplayImagesCache().Contains(*iMessage), |
|
1704 |
iFlags ) ) |
|
1705 |
||
1706 |
||
1707 |
if(!iEventHandler->IsMenuVisible()) |
|
1708 |
{ |
|
1709 |
TRAP_IGNORE( ReloadPageL() ); |
|
1710 |
} |
|
1711 |
else |
|
1712 |
{ |
|
1713 |
//Load page asynchronously after dismissing menu |
|
1714 |
//this is outdated call because it cancels Action menu which is no longer used in 9.2 |
|
1715 |
// iEventHandler->DismissMenuAndReload(); |
|
1716 |
} |
|
1717 |
} |
|
1718 |
} |
|
1719 |
||
1720 |
void CFsEmailUiHtmlViewerContainer::ReloadPageL() |
|
1721 |
{ |
|
1722 |
TRAP_IGNORE( iBrCtlInterface->HandleCommandL( ( TInt )TBrCtlDefs::ECommandIdBase + |
|
1723 |
( TInt )TBrCtlDefs::ECommandReload ) ); |
|
1724 |
} |
|
1725 |
||
1726 |
void CFsEmailUiHtmlViewerContainer::ShowAttachmentDownloadStatusL( |
|
1727 |
TFSProgress::TFSProgressStatus aProgressStatus, |
|
1728 |
const TAttachmentData& aAttachmentData ) |
|
1729 |
{ |
|
1730 |
TBool freshDraw = EFalse; |
|
1731 |
//If the indicator was displaying fetching body then we will be displaying a different indicator |
|
1732 |
//this is just to make sure the image is updated |
|
1733 |
if(iStatusIndicator) |
|
1734 |
{ |
|
1735 |
if (iStatusIndicator->Image()) |
|
1736 |
{ |
|
1737 |
if(iStatusIndicator->Image()->Handle() != iAttachmentDownloadImageHandle) |
|
1738 |
{ |
|
1739 |
freshDraw = ETrue; |
|
1740 |
} |
|
1741 |
} |
|
1742 |
} |
|
1743 |
if ( !iStatusIndicator ) |
|
1744 |
{ |
|
1745 |
TRect rect = CalcAttachmentStatusRect(); |
|
1746 |
iStatusIndicator = CFreestyleEmailUiAknStatusIndicator::NewL( rect, this ); |
|
1747 |
freshDraw = ETrue; |
|
1748 |
} |
|
1749 |
||
1750 |
if ( !iStatusIndicator->IsVisible() |
|
1751 |
|| ( aAttachmentData.downloadProgress == KNone ) |
|
1752 |
|| ( aProgressStatus == TFSProgress::EFSStatus_RequestCancelled ) ) |
|
1753 |
{ |
|
1754 |
freshDraw = ETrue; |
|
1755 |
} |
|
1756 |
||
1757 |
TInt duration = KStatusIndicatorDefaultDuration; |
|
1758 |
if ( ( aAttachmentData.downloadProgress == TFSProgress::EFSStatus_RequestComplete ) |
|
1759 |
|| ( aProgressStatus == TFSProgress::EFSStatus_RequestCancelled ) |
|
1760 |
|| ( aAttachmentData.downloadProgress == KComplete ) ) |
|
1761 |
{ |
|
1762 |
duration = KStatusIndicatorAutomaticHidingDuration; |
|
1763 |
} |
|
1764 |
||
1765 |
HBufC* statusText = NULL; |
|
1766 |
switch ( aProgressStatus ) |
|
1767 |
{ |
|
1768 |
case TFSProgress::EFSStatus_Status: |
|
1769 |
case TFSProgress::EFSStatus_RequestComplete: |
|
1770 |
{ |
|
1771 |
CDesCArray* descArray = new (ELeave) CDesCArrayFlat( 1 ); |
|
1772 |
CleanupStack::PushL( descArray ); |
|
1773 |
descArray->AppendL( aAttachmentData.fileName ); |
|
1774 |
CArrayFix<TInt>* intArray = new (ELeave) CArrayFixFlat<TInt>( 1 ); |
|
1775 |
CleanupStack::PushL( intArray ); |
|
1776 |
intArray->AppendL( aAttachmentData.downloadProgress ); |
|
1777 |
||
1778 |
statusText = StringLoader::LoadL( R_FSE_VIEWER_ATTACHMENTS_LIST_DOWNLOAD, |
|
1779 |
*descArray, |
|
1780 |
*intArray ); |
|
1781 |
CleanupStack::PopAndDestroy( intArray ); |
|
1782 |
CleanupStack::PopAndDestroy( descArray ); |
|
1783 |
CleanupStack::PushL( statusText ); |
|
1784 |
} |
|
1785 |
break; |
|
1786 |
||
1787 |
case TFSProgress::EFSStatus_RequestCancelled: |
|
1788 |
{ |
|
1789 |
statusText = aAttachmentData.fileName.AllocLC(); |
|
1790 |
} |
|
1791 |
break; |
|
1792 |
||
1793 |
default: |
|
1794 |
statusText = KNullDesC().AllocLC(); |
|
1795 |
break; |
|
1796 |
} |
|
1797 |
||
1798 |
if ( statusText->Length() > 0 ) |
|
1799 |
{ |
|
1800 |
if ( freshDraw ) |
|
1801 |
{ |
|
1802 |
CFbsBitmap* image = NULL; |
|
1803 |
CFbsBitmap* imageMask = NULL; |
|
1804 |
if ( aProgressStatus == TFSProgress::EFSStatus_RequestCancelled ) |
|
1805 |
{ |
|
1806 |
iAppUi.FsTextureManager()->ProvideBitmapL(EAttachmentsCancelDownload, image, imageMask ); |
|
1807 |
} |
|
1808 |
else |
|
1809 |
{ |
|
1810 |
iAppUi.FsTextureManager()->ProvideBitmapL(EAttachmentsDownload, image, imageMask ); |
|
1811 |
} |
|
1812 |
if(image) |
|
1813 |
{ |
|
1814 |
iAttachmentDownloadImageHandle = image->Handle(); |
|
1815 |
} |
|
1816 |
iStatusIndicator->ShowIndicatorL( image, imageMask, statusText, duration ); |
|
1817 |
} |
|
1818 |
else |
|
1819 |
{ |
|
1820 |
iStatusIndicator->SetTextL( statusText ); |
|
1821 |
if ( duration > -1 ) |
|
1822 |
{ |
|
1823 |
iStatusIndicator->HideIndicator( duration ); |
|
1824 |
} |
|
1825 |
} |
|
1826 |
} |
|
1827 |
||
1828 |
CleanupStack::Pop( statusText ); |
|
1829 |
} |
|
1830 |
||
1831 |
TBool CFsEmailUiHtmlViewerContainer::AttachmentDownloadStatusVisible() |
|
1832 |
{ |
|
1833 |
if ( iStatusIndicator ) |
|
1834 |
{ |
|
1835 |
return iStatusIndicator->IsVisible(); |
|
1836 |
} |
|
1837 |
else |
|
1838 |
{ |
|
1839 |
return EFalse; |
|
1840 |
} |
|
1841 |
} |
|
1842 |
void CFsEmailUiHtmlViewerContainer::ViewerSettingsChangedL( const TUint32 aKey ) |
|
1843 |
{ |
|
1844 |
FUNC_LOG; |
|
1845 |
if (aKey == KFreestyleEmailDownloadHTMLImages) |
|
1846 |
{ |
|
1847 |
if (iBrCtlInterface) |
|
1848 |
{ |
|
1849 |
iBrCtlInterface->SetBrowserSettingL( |
|
1850 |
TBrCtlDefs::ESettingsAutoLoadImages, |
|
1851 |
iViewerSettings->AutoLoadImages() ); |
|
1852 |
if (iViewerSettings->AutoLoadImages() && iMessage) |
|
1853 |
{ |
|
1854 |
LoadContentFromMailMessageL(iMessage, EFalse); |
|
1855 |
} |
|
1856 |
} |
|
1857 |
} |
|
1858 |
} |
|
1859 |
||
1860 |
void CFsEmailUiHtmlViewerContainer::HideDownloadStatus() |
|
1861 |
{ |
|
1862 |
if ( iStatusIndicator ) |
|
1863 |
{ |
|
1864 |
iStatusIndicator->MakeVisible( EFalse ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
1865 |
iStatusIndicator->HideIndicator(); |
64 | 1866 |
} |
1867 |
} |
|
1868 |
||
1869 |
TRect CFsEmailUiHtmlViewerContainer::CalcAttachmentStatusRect() |
|
1870 |
{ |
|
1871 |
TRect rect( Rect() ); |
|
1872 |
TPoint topLeft = rect.iTl; |
|
1873 |
TPoint bottomRight = rect.iBr; |
|
1874 |
TPoint statusTopLeft( topLeft.iX + KStatusIndicatorXMargin, bottomRight.iY - KStatusIndicatorHeight + 1 ); |
|
1875 |
TPoint statusBottomRight( bottomRight.iX - KStatusIndicatorXMargin, bottomRight.iY ); |
|
1876 |
rect = TRect(statusTopLeft, statusBottomRight); |
|
1877 |
rect.Move(0, -KStatusIndicatorBottomMargin); |
|
1878 |
return rect; |
|
1879 |
} |
|
1880 |
||
1881 |
void CFsEmailUiHtmlViewerContainer::TouchFeedback() |
|
1882 |
{ |
|
1883 |
iTouchFeedBack->InstantFeedback(this, ETouchFeedbackBasic); |
|
1884 |
} |
|
1885 |
||
1886 |
/** |
|
1887 |
* The body fetch link is cmail://body/fetch. Look for the URL separator |
|
1888 |
* and the presence of cmail and body on the url. |
|
1889 |
* @param aUrl |
|
1890 |
* return ETrue for a valid body URL |
|
1891 |
*/ |
|
1892 |
TBool CFsEmailUiHtmlViewerContainer::IsMessageBodyURLL(const TDesC& aUrl) |
|
1893 |
{ |
|
1894 |
TInt index = aUrl.Find(KURLSchemeSeparator); |
|
1895 |
if (index == KErrNotFound) |
|
1896 |
{ |
|
1897 |
return EFalse; |
|
1898 |
} |
|
1899 |
else |
|
1900 |
{ |
|
1901 |
if (aUrl.Compare(KURLLoadImages()) == 0) |
|
1902 |
{ |
|
1903 |
iBrCtlInterface->HandleCommandL(TBrCtlDefs::ECommandLoadImages + TBrCtlDefs::ECommandIdBase); |
|
1904 |
return ETrue; |
|
1905 |
} |
|
1906 |
else if (aUrl.Compare(KURLDisplayImages()) == 0) |
|
1907 |
{ |
|
1908 |
DisplayStatusIndicatorL(KStatusIndicatorAutomaticHidingDuration); |
|
1909 |
if( iMessage ) |
|
1910 |
{ |
|
1911 |
iAppUi.DisplayImagesCache().AddMessageL(*iMessage); |
|
1912 |
} |
|
1913 |
iBrCtlInterface->HandleCommandL(TBrCtlDefs::ECommandLoadImages + TBrCtlDefs::ECommandIdBase); |
|
1914 |
return ETrue; |
|
1915 |
} |
|
1916 |
else if (aUrl.Compare(KURLCollapseHeader()) == 0) |
|
1917 |
{ |
|
1918 |
TouchFeedback(); |
|
1919 |
iFlags.ClearAll(); |
|
1920 |
return ETrue; |
|
1921 |
} |
|
1922 |
else if (aUrl.Compare(KURLExpandHeader()) == 0) |
|
1923 |
{ |
|
1924 |
TouchFeedback(); |
|
1925 |
iFlags.Set( CFreestyleMessageHeaderHTML::EHeaderExpanded ); |
|
1926 |
return ETrue; |
|
1927 |
} |
|
1928 |
else if ( aUrl.Find( KURLExpandItem() ) == 0 ) { |
|
1929 |
const TPtrC item( aUrl.Mid( KURLExpandItem().Length() ) ); |
|
1930 |
if ( item.Find( KURLItemTo() ) == 0 ) |
|
1931 |
{ |
|
1932 |
iFlags.Assign( CFreestyleMessageHeaderHTML::EToExpanded, ETrue ); |
|
1933 |
} |
|
1934 |
else if ( item.Find( KURLItemCc() ) == 0 ) |
|
1935 |
{ |
|
1936 |
iFlags.Assign( CFreestyleMessageHeaderHTML::ECcExpanded, ETrue ); |
|
1937 |
} |
|
1938 |
else if ( item.Find( KURLItemBcc() ) == 0 ) |
|
1939 |
{ |
|
1940 |
iFlags.Assign( CFreestyleMessageHeaderHTML::EBccExpanded, ETrue ); |
|
1941 |
} |
|
1942 |
else if ( item.Find( KURLItemAttachments() ) == 0 ) |
|
1943 |
{ |
|
1944 |
iFlags.Assign( CFreestyleMessageHeaderHTML::EAttachmentExpanded, ETrue ); |
|
1945 |
} |
|
1946 |
return ETrue; |
|
1947 |
} else if (aUrl.Left(index).CompareF(KURLSchemeCmail) == 0) |
|
1948 |
{ |
|
1949 |
TInt bodyIndex = aUrl.Find(KURLTypeBody); |
|
1950 |
if (bodyIndex == KErrNotFound) |
|
1951 |
{ |
|
1952 |
return EFalse; |
|
1953 |
} |
|
1954 |
else |
|
1955 |
{ |
|
1956 |
TPtrC16 data= aUrl.Mid(bodyIndex); |
|
1957 |
TInt separator = data.Find(KURLSlash); |
|
1958 |
if(separator == KErrNotFound) |
|
1959 |
{ |
|
1960 |
return EFalse; |
|
1961 |
} |
|
1962 |
else |
|
1963 |
{ |
|
1964 |
TPtrC16 temp = data.Mid(separator+1); |
|
1965 |
TLex lex(temp); |
|
1966 |
lex.Val(iScrollPosition); |
|
1967 |
} |
|
1968 |
return ETrue; |
|
1969 |
} |
|
1970 |
||
1971 |
} |
|
1972 |
else |
|
1973 |
{ |
|
1974 |
return EFalse; |
|
1975 |
} |
|
1976 |
} |
|
1977 |
} |
|
1978 |
||
1979 |
// --------------------------------------------------------------------------- |
|
1980 |
// From MBrCtlWindowObserver |
|
1981 |
// --------------------------------------------------------------------------- |
|
1982 |
// |
|
1983 |
CBrCtlInterface* CFsEmailUiHtmlViewerContainer::OpenWindowL( TDesC& /*aUrl*/, TDesC* /*aTargetName*/, |
|
1984 |
TBool /*aUserInitiated*/, TAny* /*aReserved*/ ) |
|
1985 |
{ |
|
1986 |
return iBrCtlInterface; |
|
1987 |
} |
|
1988 |
||
1989 |
// --------------------------------------------------------------------------- |
|
1990 |
// From MBrCtlWindowObserver |
|
1991 |
// --------------------------------------------------------------------------- |
|
1992 |
// |
|
1993 |
CBrCtlInterface* CFsEmailUiHtmlViewerContainer::FindWindowL( const TDesC& /*aTargetName*/ ) const |
|
1994 |
{ |
|
1995 |
return NULL; |
|
1996 |
} |
|
1997 |
||
1998 |
// --------------------------------------------------------------------------- |
|
1999 |
// From MBrCtlWindowObserver |
|
2000 |
// --------------------------------------------------------------------------- |
|
2001 |
// |
|
2002 |
void CFsEmailUiHtmlViewerContainer::HandleWindowCommandL( const TDesC& /*aTargetName*/, |
|
2003 |
TBrCtlWindowCommand /*aCommand*/ ) |
|
2004 |
{ |
|
2005 |
||
2006 |
} |
|
2007 |
||
2008 |
// --------------------------------------------------------------------------- |
|
2009 |
// Check if a tap on the URL requires browser(standalone) to be launched |
|
2010 |
// --------------------------------------------------------------------------- |
|
2011 |
// |
|
2012 |
TBool CFsEmailUiHtmlViewerContainer::NeedToLaunchBrowserL( const TDesC& aUrl ) |
|
2013 |
{ |
|
2014 |
TBool launchBrowser( ETrue ); |
|
2015 |
// look for file:/// |
|
2016 |
_LIT( KFileLink, "file:///"); |
|
2017 |
_LIT( KUrlLink, "http"); |
|
2018 |
||
2019 |
// This might be linking to header.html or body.html frames |
|
2020 |
// Ignore them. |
|
2021 |
if ( aUrl.Left( KFileLink().Length() ).CompareF( KFileLink ) == 0 ) |
|
2022 |
{ |
|
2023 |
//Now there is a chance that this could be from HTML folder |
|
2024 |
// Replace all slash character with backslash characters |
|
2025 |
HBufC* embeddedUrl = aUrl.AllocLC(); |
|
2026 |
TPtr ptr = embeddedUrl->Des(); |
|
2027 |
||
2028 |
_LIT( KBackslash, "\\" ); |
|
2029 |
for ( TInt pos = ptr.Locate('/'); pos >= 0; pos = ptr.Locate('/') ) |
|
2030 |
{ |
|
2031 |
ptr.Replace( pos, 1, KBackslash ); |
|
2032 |
} |
|
2033 |
||
2034 |
// Check whether given url refers to file in the html folder |
|
2035 |
TInt pos = embeddedUrl->FindF( iHtmlFolderPath ); |
|
2036 |
CleanupStack::PopAndDestroy( embeddedUrl ); |
|
2037 |
pos >= 0 ? launchBrowser = EFalse : ETrue; |
|
2038 |
} |
|
2039 |
// Ignore links starting with cmail:// |
|
2040 |
else if ( aUrl.Left( KURLSchemeCmail().Length() ).CompareF( KURLSchemeCmail ) == 0 ) |
|
2041 |
{ |
|
2042 |
launchBrowser = EFalse; |
|
2043 |
} |
|
2044 |
// THAA-82BEAZ - show popup first |
|
2045 |
else if ( aUrl.Left(KUrlLink().Length() ).CompareF( KUrlLink ) == 0 ) |
|
2046 |
{ |
|
2047 |
launchBrowser = EFalse; |
|
2048 |
} |
|
2049 |
// end THAA-82BEAZ |
|
2050 |
||
2051 |
return launchBrowser; |
|
2052 |
} |
|
2053 |
||
2054 |
// --------------------------------------------------------------------------- |
|
2055 |
// Launch the browser as a standalone app |
|
2056 |
// --------------------------------------------------------------------------- |
|
2057 |
// |
|
2058 |
void CFsEmailUiHtmlViewerContainer::LaunchBrowserL( const TDesC& aUrl ) |
|
2059 |
{ |
|
2060 |
CSchemeHandler* handler = CSchemeHandler::NewL( aUrl ); |
|
2061 |
CleanupStack::PushL( handler ); |
|
2062 |
handler->HandleUrlStandaloneL(); |
|
2063 |
CleanupStack::PopAndDestroy( handler ); |
|
2064 |
} |
|
2065 |
||
2066 |
void CFsEmailUiHtmlViewerContainer::PrepareBodyHtmlL( const TDesC& aFileName ) |
|
2067 |
{ |
|
2068 |
||
2069 |
if( iMessage ) |
|
2070 |
{ |
|
2071 |
CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL(); |
|
2072 |
||
2073 |
if ( htmlBodyPart ) |
|
2074 |
{ |
|
2075 |
CleanupStack::PushL( htmlBodyPart ); |
|
2076 |
// Copy html body part to email html file |
|
2077 |
CopyToHtmlFileL( *htmlBodyPart, aFileName ); |
|
2078 |
CleanupStack::PopAndDestroy( htmlBodyPart ); |
|
2079 |
} |
|
2080 |
else |
|
2081 |
{ |
|
2082 |
CFSMailMessagePart* textBodyPart = iMessage->PlainTextBodyPartL(); |
|
2083 |
||
2084 |
if ( textBodyPart ) |
|
2085 |
{ |
|
2086 |
CleanupStack::PushL( textBodyPart ); |
|
2087 |
// Copy html body part to email html file |
|
2088 |
ConvertToHtmlFileL( *textBodyPart, aFileName ); |
|
2089 |
CleanupStack::PopAndDestroy( textBodyPart ); |
|
2090 |
} |
|
2091 |
else |
|
2092 |
{ |
|
2093 |
User::Leave( KErrNotFound ); |
|
2094 |
} |
|
2095 |
} |
|
2096 |
} |
|
2097 |
} |
|
2098 |
||
2099 |
void CFsEmailUiHtmlViewerContainer::WriteEmptyBodyHtmlL( const TDesC& aFileName ) |
|
2100 |
{ |
|
2101 |
FUNC_LOG; |
|
2102 |
TFileName targetFileName; |
|
2103 |
targetFileName.Copy( iTempHtmlFolderPath ); |
|
2104 |
targetFileName.Append( aFileName ); |
|
2105 |
||
2106 |
RFile targetFile; |
|
2107 |
CleanupClosePushL( targetFile ); |
|
2108 |
User::LeaveIfError( targetFile.Replace( iFs, targetFileName, EFileWrite ) ); |
|
2109 |
User::LeaveIfError( targetFile.Write( KHTMLEmptyContent ) ); |
|
2110 |
CleanupStack::PopAndDestroy( &targetFile ); |
|
2111 |
} |
|
2112 |
||
2113 |
void CFsEmailUiHtmlViewerContainer::DisplayStatusIndicatorL(TInt aDuration) |
|
2114 |
{ |
|
2115 |
FUNC_LOG; |
|
2116 |
TRect rect = CalcAttachmentStatusRect(); |
|
2117 |
if(!iStatusIndicator) |
|
2118 |
{ |
|
2119 |
iStatusIndicator = CFreestyleEmailUiAknStatusIndicator::NewL( rect, this ); |
|
2120 |
} |
|
2121 |
CFbsBitmap* image = NULL; |
|
2122 |
CFbsBitmap* imageMask = NULL; |
|
2123 |
HBufC* statusText = NULL; |
|
2124 |
statusText = StringLoader::LoadL(R_FREESTYLE_EMAIL_UI_VIEWER_FETCHING_CONTENT_TEXT); |
|
2125 |
iAppUi.FsTextureManager()->ProvideBitmapL(EStatusTextureSynchronising, image, imageMask ); |
|
2126 |
iStatusIndicator->ShowIndicatorL( image, imageMask, statusText, aDuration, ETrue ); |
|
2127 |
} |
|
2128 |
||
2129 |
void CFsEmailUiHtmlViewerContainer::MailListModelUpdatedL() |
|
2130 |
{ |
|
2131 |
FUNC_LOG; |
|
2132 |
UpdateOverlayButtons( IsVisible() ); |
|
2133 |
} |
|
2134 |
||
2135 |
||
2136 |
void CFsEmailUiHtmlViewerContainer::WriteToFileL(const TDesC& aFileName, RBuf& aHtmlText) |
|
2137 |
{ |
|
2138 |
_LIT( KCharsetUtf8, "UTF-8" ); |
|
2139 |
||
2140 |
HBufC8* content8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aHtmlText ); |
|
2141 |
CleanupStack::PushL( content8 ); |
|
2142 |
||
2143 |
RFile targetFile; |
|
2144 |
CleanupClosePushL( targetFile ); |
|
2145 |
User::LeaveIfError( targetFile.Replace( iFs, aFileName, EFileWrite ) ); |
|
2146 |
||
2147 |
RBuf8 messageHeader; |
|
2148 |
TInt bufSize = KHtmlHeader1().Length() + KCharsetUtf8().Length() + KHtmlHeader2().Length(); |
|
2149 |
messageHeader.CreateL( bufSize ); |
|
2150 |
messageHeader.CleanupClosePushL(); |
|
2151 |
||
2152 |
messageHeader.Append( KHtmlHeader1 ); |
|
2153 |
messageHeader.Append( KCharsetUtf8 ); |
|
2154 |
messageHeader.Append( KHtmlHeader2 ); |
|
2155 |
||
2156 |
RFileWriteStream fileStream( targetFile ); |
|
2157 |
fileStream.PushL(); |
|
2158 |
fileStream.WriteL( messageHeader.Ptr(), messageHeader.Length() ); |
|
2159 |
||
2160 |
TInt bufPos( 0 ); |
|
2161 |
TInt bufTotalSize = content8->Size(); |
|
2162 |
||
2163 |
while ( bufPos < bufTotalSize ) |
|
2164 |
{ |
|
2165 |
TInt segmentLength = content8->Mid( bufPos ).Length(); |
|
2166 |
fileStream.WriteL( content8->Mid( bufPos ).Ptr(), segmentLength ); |
|
2167 |
bufPos += segmentLength; |
|
2168 |
} |
|
2169 |
||
2170 |
fileStream.CommitL(); |
|
2171 |
||
2172 |
CleanupStack::PopAndDestroy( &fileStream ); |
|
2173 |
CleanupStack::PopAndDestroy( &messageHeader ); |
|
2174 |
CleanupStack::PopAndDestroy( &targetFile ); |
|
2175 |
CleanupStack::PopAndDestroy( content8 ); |
|
2176 |
} |
|
2177 |
||
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2178 |
HBufC* CFsEmailUiHtmlViewerContainer::CreateModifiedUrlIfNeededL( |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2179 |
const TDesC& aUrl ) |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2180 |
{ |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2181 |
_LIT( KFileLink, "file:///"); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2182 |
HBufC* modifiedUrl = NULL; |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2183 |
|
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2184 |
// check if this really is file-URL |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2185 |
if ( aUrl.Left( KFileLink().Length() ).CompareF( KFileLink ) == 0 ) |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2186 |
{ |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2187 |
// convert URL-style slashes to backslashes |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2188 |
_LIT( KBackslash, "\\" ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2189 |
HBufC* url = aUrl.Mid( KFileLink().Length() ).AllocLC(); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2190 |
TPtr urlPtr = url->Des(); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2191 |
for ( TInt pos = urlPtr.Locate('/'); pos >= 0; pos = urlPtr.Locate('/') ) |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2192 |
{ |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2193 |
urlPtr.Replace( pos, 1, KBackslash ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2194 |
} |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2195 |
// check if the file exists, if not convert the file-URL to http-URL |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2196 |
// (i.e., remove the whole path and replace the prefix with "http:") |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2197 |
if ( !BaflUtils::FileExists( iFs, *url ) ) |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2198 |
{ |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2199 |
TInt pos = url->FindF( iTempHtmlFolderPath ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2200 |
if ( pos >= 0 ) |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2201 |
{ |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2202 |
_LIT( KHttpPrefix, "http://" ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2203 |
TPtrC filename = url->Mid( pos + iTempHtmlFolderPath.Length() ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2204 |
modifiedUrl = HBufC::NewL( filename.Length() + KHttpPrefix().Length() ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2205 |
TPtr modifiedPtr = modifiedUrl->Des(); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2206 |
modifiedPtr.Append( KHttpPrefix ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2207 |
modifiedPtr.Append( filename ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2208 |
} |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2209 |
} |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2210 |
CleanupStack::PopAndDestroy( url ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2211 |
} |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2212 |
return modifiedUrl; |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
2213 |
} |
64 | 2214 |
|
2215 |
||
2216 |
/****************************************************************************** |
|
2217 |
* class PlainTextToHtmlConverter |
|
2218 |
******************************************************************************/ |
|
2219 |
||
2220 |
||
2221 |
||
2222 |
// ----------------------------------------------------------------------------- |
|
2223 |
// PlainTextToHtmlConverter::PlainTextToHtmlL |
|
2224 |
// |
|
2225 |
// ----------------------------------------------------------------------------- |
|
2226 |
// |
|
2227 |
void PlainTextToHtmlConverter::PlainTextToHtmlL(const TDesC& aPlainText, RBuf& aHtmlText) |
|
2228 |
{ |
|
2229 |
const TInt KAllocSize = 1024; |
|
2230 |
||
2231 |
aHtmlText.Close(); |
|
2232 |
aHtmlText.Create( aPlainText.Length() + KAllocSize ); |
|
2233 |
||
2234 |
const TInt searhCases( CFindItemEngine::EFindItemSearchURLBin ); |
|
2235 |
CFindItemEngine* itemEngine = CFindItemEngine::NewL( aPlainText, CFindItemEngine::TFindItemSearchCase( searhCases ) ); |
|
2236 |
CleanupStack::PushL ( itemEngine ); |
|
2237 |
||
2238 |
TInt currentPos = 0; |
|
2239 |
CFindItemEngine::SFoundItem item; |
|
2240 |
for ( TBool available(itemEngine->Item(item)); available; available=itemEngine->NextItem(item) ) |
|
2241 |
{ |
|
2242 |
if ( item.iStartPos < currentPos ) |
|
2243 |
{ |
|
2244 |
break; |
|
2245 |
} |
|
2246 |
||
2247 |
TPtrC textPtr = aPlainText.Mid( currentPos, item.iStartPos-currentPos ); |
|
2248 |
ConvertTextL( textPtr, aHtmlText ); |
|
2249 |
||
2250 |
TPtrC urlPtr = aPlainText.Mid( item.iStartPos, item.iLength ); |
|
2251 |
ConvertUrlL( urlPtr, aHtmlText); |
|
2252 |
||
2253 |
currentPos = item.iStartPos + item.iLength; |
|
2254 |
} |
|
2255 |
||
2256 |
TInt len = aPlainText.Length(); |
|
2257 |
if ( currentPos < len ) |
|
2258 |
{ |
|
2259 |
TPtrC textPtr = aPlainText.Mid( currentPos ); |
|
2260 |
ConvertTextL( textPtr, aHtmlText ); |
|
2261 |
} |
|
2262 |
||
2263 |
CleanupStack::PopAndDestroy( itemEngine ); |
|
2264 |
} |
|
2265 |
||
2266 |
||
2267 |
// ----------------------------------------------------------------------------- |
|
2268 |
// PlainTextToHtmlConverter::ConvertTextL |
|
2269 |
// |
|
2270 |
// ----------------------------------------------------------------------------- |
|
2271 |
// |
|
2272 |
void PlainTextToHtmlConverter::ConvertTextL(const TDesC& aSource, RBuf& aTarget) |
|
2273 |
{ |
|
2274 |
const TInt KAllocSize = 1024; |
|
2275 |
const TInt KEntitySize = 32; |
|
2276 |
||
2277 |
TInt count = aSource.Length(); |
|
2278 |
for ( TInt i=0; i<count; i++ ) |
|
2279 |
{ |
|
2280 |
if ( aTarget.Length() + KEntitySize >= aTarget.MaxLength() ) |
|
2281 |
{ |
|
2282 |
aTarget.ReAllocL( aTarget.MaxLength() + KAllocSize ); |
|
2283 |
} |
|
2284 |
||
2285 |
TText ch = aSource[i]; |
|
2286 |
switch( ch ) |
|
2287 |
{ |
|
2288 |
case KSOH: // end of line for IMAP and POP |
|
2289 |
aTarget.Append( KHtmlLineBreakCRLF ); |
|
2290 |
break; |
|
2291 |
case KLF: // line feed |
|
2292 |
case KUnicodeNewLineCharacter: |
|
2293 |
case KUnicodeParagraphCharacter: |
|
2294 |
aTarget.Append(KHtmlLineBreak); |
|
2295 |
break; |
|
2296 |
case KQuotation: |
|
2297 |
aTarget.Append( KHtmlQuotation ); |
|
2298 |
break; |
|
2299 |
case KAmpersand: |
|
2300 |
aTarget.Append( KHtmlAmpersand ); |
|
2301 |
break; |
|
2302 |
case KGreaterThan: |
|
2303 |
aTarget.Append( KHtmlGreaterThan ); |
|
2304 |
break; |
|
2305 |
case KLessThan: |
|
2306 |
aTarget.Append( KHtmlLessThan ); |
|
2307 |
break; |
|
2308 |
default: |
|
2309 |
aTarget.Append( ch ); |
|
2310 |
break; |
|
2311 |
} |
|
2312 |
} |
|
2313 |
} |
|
2314 |
||
2315 |
||
2316 |
// ----------------------------------------------------------------------------- |
|
2317 |
// PlainTextToHtmlConverter::ConvertUrlL |
|
2318 |
// |
|
2319 |
// ----------------------------------------------------------------------------- |
|
2320 |
// |
|
2321 |
void PlainTextToHtmlConverter::ConvertUrlL(const TDesC& aSource, RBuf& aTarget) |
|
2322 |
{ |
|
2323 |
_LIT( KSchemeDelimiter, "://" ); |
|
2324 |
_LIT( KUrlFormat, "<a href=\"%S\">%S</a>" ); |
|
2325 |
_LIT( KUrlFormatWithHttp, "<a href=\"http://%S\">%S</a>" ); |
|
2326 |
||
2327 |
TPtrC format( KUrlFormat() ); |
|
2328 |
if ( aSource.FindF( KSchemeDelimiter() ) == KErrNotFound ) |
|
2329 |
{ |
|
2330 |
format.Set( KUrlFormatWithHttp() ); |
|
2331 |
} |
|
2332 |
||
2333 |
HBufC* formatBuffer = HBufC::NewLC( format.Length() + aSource.Length() * 2 ); |
|
2334 |
formatBuffer->Des().Format( format, &aSource, &aSource ); |
|
2335 |
||
2336 |
TInt len = formatBuffer->Des().Length(); |
|
2337 |
if ( aTarget.Length() + len >= aTarget.MaxLength() ) |
|
2338 |
{ |
|
2339 |
aTarget.ReAllocL( aTarget.MaxLength() + len ); |
|
2340 |
} |
|
2341 |
||
2342 |
aTarget.Append( *formatBuffer ); |
|
2343 |
||
2344 |
CleanupStack::PopAndDestroy( formatBuffer ); |
|
2345 |
} |