|
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 |
|
25 //<cmail> |
|
26 #include "CFSMailMessage.h" |
|
27 //</cmail> |
|
28 #include <brctlinterface.h> |
|
29 #include <sysutil.h> |
|
30 |
|
31 |
|
32 #include "FreestyleEmailUiAppui.h" |
|
33 #include "FreestyleEmailUiUtilities.h" |
|
34 #include "FreestyleEmailUiHtmlViewerContainer.h" |
|
35 #include "FreestyleEmailUiHtmlViewerView.h" |
|
36 #include "FreestyleEmailUiShortcutBinding.h" |
|
37 |
|
38 #include "FreestyleMessageHeaderHTML.h" |
|
39 #include "FreestyleMessageHeaderURLEventHandler.h" |
|
40 |
|
41 _LIT( KContentIdPrefix, "cid:" ); |
|
42 _LIT( KCDrive, "c:" ); |
|
43 _LIT( KHtmlPath, "HtmlFile\\" ); |
|
44 _LIT( KTempHtmlPath, "temp\\" ); |
|
45 _LIT( KAllFiles, "*" ); |
|
46 |
|
47 _LIT( KHeaderHtmlFile, "header.html" ); |
|
48 _LIT( KBodyHtmlFile, "body.html" ); |
|
49 _LIT( KMessageHtmlFile, "email.html" ); |
|
50 _LIT( KZDrive, "z:" ); |
|
51 _LIT( KHtmlFlagFile, "html.flag" ); |
|
52 |
|
53 // <cmail> |
|
54 // Constants used in html content modification |
|
55 const TInt KMaxCharsToSearch( 200 ); |
|
56 _LIT8( KStartTag, "<html" ); |
|
57 _LIT8( KHeadTag, "<head>"); |
|
58 _LIT8( KHtmlHeader1, "<html><head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset="); |
|
59 _LIT8( KHtmlHeader2, "\"/></head><body>\xD\xA"); |
|
60 _LIT8( KHtmlHeader3, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%S\">\n"); |
|
61 _LIT8( KHtmlEndTags, "\xD\xA</body></html>\xD\xA"); |
|
62 _LIT8( KCharsetTag8, "charset"); |
|
63 _LIT( KCharsetTag, "charset"); |
|
64 _LIT8( KHTMLEmptyContent, "<HTML><BODY></BODY></HTML>"); |
|
65 _LIT( KHTMLDataScheme, "data:0"); |
|
66 |
|
67 // </cmail> |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // Two-phased constructor. |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CFsEmailUiHtmlViewerContainer* CFsEmailUiHtmlViewerContainer::NewL( |
|
74 CFreestyleEmailUiAppUi& aAppUi, CFsEmailUiHtmlViewerView& aView ) |
|
75 { |
|
76 FUNC_LOG; |
|
77 CFsEmailUiHtmlViewerContainer* self = |
|
78 new (ELeave) CFsEmailUiHtmlViewerContainer( aAppUi, aView ); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 CleanupStack::Pop( self ); |
|
82 return self; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // C++ constructor. |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 CFsEmailUiHtmlViewerContainer::CFsEmailUiHtmlViewerContainer( |
|
90 CFreestyleEmailUiAppUi& aAppUi, CFsEmailUiHtmlViewerView& aView ) |
|
91 : |
|
92 iAppUi( aAppUi ), |
|
93 iView( aView ), |
|
94 iFs( CCoeEnv::Static()->FsSession() ), |
|
95 iFirstTime( ETrue ) |
|
96 { |
|
97 FUNC_LOG; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // Destructor. |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 CFsEmailUiHtmlViewerContainer::~CFsEmailUiHtmlViewerContainer() |
|
105 { |
|
106 FUNC_LOG; |
|
107 if ( iObservingDownload && iAppUi.DownloadInfoMediator() ) |
|
108 { |
|
109 iAppUi.DownloadInfoMediator()->StopObserving( this ); |
|
110 } |
|
111 iFile.Close(); |
|
112 iLinkContents.Close(); |
|
113 iMessageParts.Close(); |
|
114 delete iEventHandler; |
|
115 delete iBrCtlInterface; |
|
116 iConnection.Close(); |
|
117 iSocketServer.Close(); |
|
118 } |
|
119 |
|
120 // <cmail> Because of browser changes, followings must be performed before iAppUi.exit() |
|
121 void CFsEmailUiHtmlViewerContainer::PrepareForExit() |
|
122 { |
|
123 FUNC_LOG; |
|
124 if ( iObservingDownload && iAppUi.DownloadInfoMediator() ) |
|
125 { |
|
126 iAppUi.DownloadInfoMediator()->StopObserving( this ); |
|
127 iObservingDownload = EFalse; |
|
128 } |
|
129 delete iBrCtlInterface; |
|
130 iBrCtlInterface = NULL; |
|
131 iConnection.Close(); |
|
132 iSocketServer.Close(); |
|
133 } |
|
134 // </cmail> |
|
135 |
|
136 void CFsEmailUiHtmlViewerContainer::ConstructL() |
|
137 { |
|
138 FUNC_LOG; |
|
139 |
|
140 SetHtmlFolderPathL(); |
|
141 BaflUtils::EnsurePathExistsL( iFs, iHtmlFolderPath ); |
|
142 SetTempHtmlFolderPath(); |
|
143 BaflUtils::EnsurePathExistsL( iFs, iTempHtmlFolderPath ); |
|
144 SetHTMLResourceFlagFullName(); |
|
145 EnsureHTMLResourceL(); |
|
146 |
|
147 CreateWindowL(); |
|
148 SetRect( iAppUi.ClientRect() ); |
|
149 |
|
150 |
|
151 TUint brCtlCapabilities = TBrCtlDefs::ECapabilityClientResolveEmbeddedURL | |
|
152 TBrCtlDefs::ECapabilityDisplayScrollBar | |
|
153 TBrCtlDefs::ECapabilityClientNotifyURL | |
|
154 TBrCtlDefs::ECapabilityLoadHttpFw | |
|
155 TBrCtlDefs::ECapabilityCursorNavigation; |
|
156 |
|
157 // Set browsercontrol to whole screen |
|
158 TRect rect( TPoint(), Size() ); |
|
159 |
|
160 iBrCtlInterface = CreateBrowserControlL( this, rect, brCtlCapabilities, |
|
161 TBrCtlDefs::ECommandIdBase, NULL, this, this ); |
|
162 |
|
163 iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsEmbedded, ETrue ); |
|
164 iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsAutoLoadImages, ETrue ); |
|
165 iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsPageOverview, EFalse ); |
|
166 iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsTextWrapEnabled, ETrue ); |
|
167 iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsFontSize, TBrCtlDefs::EFontSizeLevelLarger ); |
|
168 |
|
169 iEventHandler = CFreestyleMessageHeaderURLEventHandler::NewL( iAppUi, iView ); |
|
170 ActivateL(); |
|
171 } |
|
172 |
|
173 // Getter for br contro, interface |
|
174 CBrCtlInterface* CFsEmailUiHtmlViewerContainer::BrowserControlIf() |
|
175 { |
|
176 FUNC_LOG; |
|
177 return iBrCtlInterface; |
|
178 } |
|
179 |
|
180 void CFsEmailUiHtmlViewerContainer::LoadContentFromFileL( const TDesC& aFileName ) |
|
181 { |
|
182 FUNC_LOG; |
|
183 iBrCtlInterface->LoadFileL( aFileName ); |
|
184 } |
|
185 |
|
186 void CFsEmailUiHtmlViewerContainer::LoadContentFromFileL( RFile& aFile ) |
|
187 { |
|
188 FUNC_LOG; |
|
189 iBrCtlInterface->LoadFileL( aFile ); |
|
190 } |
|
191 |
|
192 void CFsEmailUiHtmlViewerContainer::LoadContentFromUrlL( const TDesC& aUrl ) |
|
193 { |
|
194 FUNC_LOG; |
|
195 iBrCtlInterface->LoadUrlL( aUrl ); |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // Loads content from given mail message. |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 void CFsEmailUiHtmlViewerContainer::LoadContentFromMailMessageL( |
|
203 CFSMailMessage* aMailMessage ) |
|
204 { |
|
205 FUNC_LOG; |
|
206 ASSERT( aMailMessage ); |
|
207 iMessage = aMailMessage; |
|
208 |
|
209 TPath headerHtmlFile; |
|
210 headerHtmlFile.Copy( iHtmlFolderPath ); |
|
211 headerHtmlFile.Append( KHeaderHtmlFile ); |
|
212 |
|
213 // insert email header into email.html file |
|
214 // CFreestyleMessageHeaderHTML will replace contents of email.html |
|
215 // So, no need to clear the contents |
|
216 CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile ); |
|
217 |
|
218 // Remove all previously created files from temporary HTML folder |
|
219 EmptyTempHtmlFolderL(); |
|
220 |
|
221 CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL(); |
|
222 |
|
223 if ( htmlBodyPart ) |
|
224 { |
|
225 CleanupStack::PushL( htmlBodyPart ); |
|
226 |
|
227 RFile htmlFile = htmlBodyPart->GetContentFileL(); |
|
228 CleanupClosePushL( htmlFile ); |
|
229 |
|
230 // Copy html body part to email html file |
|
231 CopyFileToHtmlFileL( htmlFile, KBodyHtmlFile, *htmlBodyPart ); |
|
232 |
|
233 CleanupStack::PopAndDestroy( &htmlFile ); |
|
234 CleanupStack::PopAndDestroy( htmlBodyPart ); |
|
235 } |
|
236 else |
|
237 { |
|
238 CFSMailMessagePart* textBodyPart = iMessage->PlainTextBodyPartL();; |
|
239 |
|
240 if ( textBodyPart ) |
|
241 { |
|
242 CleanupStack::PushL( textBodyPart ); |
|
243 //For now do not do any conversion just add start and end..Let browser display plain text as is |
|
244 //Later need to refine this and add conversions |
|
245 //htmlFile = textBodyPart->GetContentFileL(); |
|
246 //Need to get buffer in this case, file does not work |
|
247 //HBufC* contentBuffer=HBufC::NewLC(textBodyPart->ContentSize()); |
|
248 |
|
249 HBufC* contentBuffer=HBufC::NewLC(textBodyPart->FetchedContentSize()); |
|
250 TPtr bufPtr(contentBuffer->Des()); |
|
251 |
|
252 textBodyPart->GetContentToBufferL(bufPtr,0); |
|
253 HBufC8* contentBuffer8=HBufC8::NewLC(contentBuffer->Length()); |
|
254 |
|
255 contentBuffer8->Des().Copy(*contentBuffer); |
|
256 CopyFileToHtmlFileL( *contentBuffer8, KBodyHtmlFile, *textBodyPart ); |
|
257 |
|
258 CleanupStack::PopAndDestroy( contentBuffer8 ); |
|
259 CleanupStack::PopAndDestroy( contentBuffer ); |
|
260 CleanupStack::PopAndDestroy( textBodyPart ); |
|
261 } |
|
262 |
|
263 } |
|
264 // pass the emailHtmlFile to the browser for it to load |
|
265 TPath emailHtmlFile; |
|
266 emailHtmlFile.Copy( iHtmlFolderPath ); |
|
267 emailHtmlFile.Append( KMessageHtmlFile ); |
|
268 LoadContentFromFileL( emailHtmlFile ); |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------------------------- |
|
272 // Reset content |
|
273 // --------------------------------------------------------------------------- |
|
274 // |
|
275 void CFsEmailUiHtmlViewerContainer::ResetContent() |
|
276 { |
|
277 FUNC_LOG; |
|
278 if ( iBrCtlInterface ) |
|
279 { |
|
280 TRAP_IGNORE( iBrCtlInterface->HandleCommandL( ( TInt )TBrCtlDefs::ECommandIdBase + |
|
281 ( TInt )TBrCtlDefs::ECommandFreeMemory ) ); |
|
282 } |
|
283 iFile.Close(); |
|
284 iLinkContents.Reset(); |
|
285 iMessageParts.Reset(); |
|
286 iMessage = NULL; |
|
287 } |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // From CCoeControl. |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 CCoeControl* CFsEmailUiHtmlViewerContainer::ComponentControl( TInt aIndex ) const |
|
294 { |
|
295 FUNC_LOG; |
|
296 switch ( aIndex ) |
|
297 { |
|
298 case 0: |
|
299 { |
|
300 return iBrCtlInterface; |
|
301 } |
|
302 default: |
|
303 { |
|
304 return NULL; |
|
305 } |
|
306 } |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------------------------- |
|
310 // From CCoeControl. |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 TInt CFsEmailUiHtmlViewerContainer::CountComponentControls() const |
|
314 { |
|
315 FUNC_LOG; |
|
316 return 1; |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // From CCoeControl. |
|
321 // Draw this application's view to the screen |
|
322 // --------------------------------------------------------------------------- |
|
323 // |
|
324 void CFsEmailUiHtmlViewerContainer::Draw( const TRect& /*aRect*/ ) const |
|
325 { |
|
326 FUNC_LOG; |
|
327 // Get the standard graphics context |
|
328 CWindowGc& gc = SystemGc(); |
|
329 |
|
330 // Gets the control's extent |
|
331 TRect rect = Rect(); |
|
332 |
|
333 // Clears the screen |
|
334 gc.Clear( rect ); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // From CCoeControl. |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void CFsEmailUiHtmlViewerContainer::SizeChanged() |
|
342 { |
|
343 FUNC_LOG; |
|
344 if ( iBrCtlInterface ) |
|
345 { |
|
346 TRect rect = Rect(); |
|
347 iBrCtlInterface->SetRect( rect ); |
|
348 } |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // From CCoeControl. |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 TKeyResponse CFsEmailUiHtmlViewerContainer::OfferKeyEventL( |
|
356 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
357 { |
|
358 FUNC_LOG; |
|
359 |
|
360 TKeyResponse retVal = EKeyWasNotConsumed; |
|
361 |
|
362 // Handle keyboard shortcuts already on key down event as all keys |
|
363 // do not necessarily send the key event at all. |
|
364 if ( aType == EEventKeyDown ) |
|
365 { |
|
366 // Check keyboard shortcuts |
|
367 TInt shortcutCommand = iAppUi.ShortcutBinding().CommandForShortcutKey( |
|
368 aKeyEvent, CFSEmailUiShortcutBinding::EContextHtmlViewer ); |
|
369 |
|
370 if ( shortcutCommand != KErrNotFound ) |
|
371 { |
|
372 iView.HandleCommandL( shortcutCommand ); |
|
373 retVal = EKeyWasConsumed; |
|
374 } |
|
375 } |
|
376 |
|
377 if ( iBrCtlInterface && retVal == EKeyWasNotConsumed ) |
|
378 { |
|
379 retVal = iBrCtlInterface->OfferKeyEventL( aKeyEvent, aType ); |
|
380 } |
|
381 |
|
382 iView.SetMskL(); |
|
383 |
|
384 return retVal; |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // From MBrCtlSpecialLoadObserver. |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 void CFsEmailUiHtmlViewerContainer::NetworkConnectionNeededL( |
|
392 TInt* aConnectionPtr, |
|
393 TInt* aSockSvrHandle, |
|
394 TBool* aNewConn, |
|
395 TApBearerType* aBearerType ) |
|
396 { |
|
397 FUNC_LOG; |
|
398 *aBearerType = EApBearerTypeAllBearers; |
|
399 |
|
400 if ( iFirstTime ) |
|
401 { |
|
402 User::LeaveIfError( iSocketServer.Connect( KESockDefaultMessageSlots ) ); |
|
403 User::LeaveIfError( iConnection.Open( iSocketServer, KConnectionTypeDefault ) ); |
|
404 TCommDbConnPref prefs; |
|
405 prefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); |
|
406 prefs.SetDirection( ECommDbConnectionDirectionOutgoing ); |
|
407 prefs.SetIapId( 0 ); // Ask for access point |
|
408 User::LeaveIfError( iConnection.Start( prefs ) ); |
|
409 *aNewConn = ETrue; |
|
410 iFirstTime = EFalse; |
|
411 } |
|
412 else |
|
413 { |
|
414 *aNewConn = EFalse; |
|
415 } |
|
416 |
|
417 *aConnectionPtr = reinterpret_cast<TInt>(&iConnection); |
|
418 *aSockSvrHandle = iSocketServer.Handle(); |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------------------------- |
|
422 // From MBrCtlSpecialLoadObserver. |
|
423 // --------------------------------------------------------------------------- |
|
424 // |
|
425 TBool CFsEmailUiHtmlViewerContainer::HandleRequestL( |
|
426 RArray<TUint>* /*aTypeArray*/, CDesCArrayFlat* /*aDesArray*/ ) |
|
427 { |
|
428 FUNC_LOG; |
|
429 // Let browser control handle these |
|
430 return EFalse; |
|
431 } |
|
432 |
|
433 // --------------------------------------------------------------------------- |
|
434 // From MBrCtlSpecialLoadObserver. |
|
435 // --------------------------------------------------------------------------- |
|
436 // |
|
437 TBool CFsEmailUiHtmlViewerContainer::HandleDownloadL( |
|
438 RArray<TUint>* /*aTypeArray*/, CDesCArrayFlat* /*aDesArray*/ ) |
|
439 { |
|
440 FUNC_LOG; |
|
441 // Let browser control handle these |
|
442 return EFalse; |
|
443 } |
|
444 |
|
445 // --------------------------------------------------------------------------- |
|
446 // From MFSEmailDownloadInformationObserver. |
|
447 // --------------------------------------------------------------------------- |
|
448 // |
|
449 void CFsEmailUiHtmlViewerContainer::RequestResponseL( const TFSProgress& aEvent, |
|
450 const TPartData& aPart ) |
|
451 { |
|
452 FUNC_LOG; |
|
453 if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete ) |
|
454 { |
|
455 MBrCtlLinkContent* linkContent = NULL; |
|
456 for ( TInt ii = iMessageParts.Count() - 1; ii >= 0 && !linkContent; --ii ) |
|
457 { |
|
458 if ( iMessageParts[ii] == aPart ) |
|
459 { |
|
460 iMessageParts.Remove( ii ); |
|
461 linkContent = iLinkContents[ii]; |
|
462 iLinkContents.Remove( ii ); |
|
463 } |
|
464 } |
|
465 |
|
466 if ( !iMessageParts.Count() && iAppUi.DownloadInfoMediator() ) |
|
467 { |
|
468 iAppUi.DownloadInfoMediator()->StopObserving( this ); |
|
469 } |
|
470 |
|
471 if ( iMessage && linkContent ) |
|
472 { |
|
473 CFSMailMessagePart* part = iMessage->ChildPartL( aPart.iMessagePartId ); |
|
474 CleanupStack::PushL( part ); |
|
475 RFile contentFile = part->GetContentFileL(); |
|
476 CleanupClosePushL( contentFile ); |
|
477 HBufC8* content = ReadContentFromFileLC( contentFile ); |
|
478 linkContent->HandleResolveComplete( |
|
479 part->GetContentType(), KNullDesC(), content ); |
|
480 CleanupStack::PopAndDestroy( content ); |
|
481 CleanupStack::PopAndDestroy( &contentFile ); |
|
482 CleanupStack::PopAndDestroy( part ); |
|
483 } |
|
484 if ( iMessage ) |
|
485 { |
|
486 LoadContentFromMailMessageL( iMessage ); |
|
487 } |
|
488 } |
|
489 else if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestCancelled || |
|
490 aEvent.iProgressStatus < 0 ) |
|
491 { |
|
492 if ( iAppUi.DownloadInfoMediator() ) |
|
493 { |
|
494 iAppUi.DownloadInfoMediator()->StopObserving( this, aPart.iMessageId ); |
|
495 } |
|
496 } |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // From MBrCtlLinkResolver. |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 TBool CFsEmailUiHtmlViewerContainer::ResolveEmbeddedLinkL( |
|
504 const TDesC& aEmbeddedUrl, const TDesC& /*aCurrentUrl*/, |
|
505 TBrCtlLoadContentType /*aLoadContentType*/, |
|
506 MBrCtlLinkContent& aEmbeddedLinkContent ) |
|
507 { |
|
508 FUNC_LOG; |
|
509 TBool linkResolved = EFalse; |
|
510 |
|
511 // Check if given link contains content ID |
|
512 if ( aEmbeddedUrl.Left( KContentIdPrefix().Length() ).CompareF( KContentIdPrefix ) == 0 ) |
|
513 { |
|
514 TPtrC cid = aEmbeddedUrl.Mid( KContentIdPrefix().Length() ); |
|
515 linkResolved = ResolveLinkL( cid, ETrue, aEmbeddedLinkContent ); |
|
516 } |
|
517 else |
|
518 { |
|
519 // Replace all slash character with backslash characters |
|
520 HBufC* embeddedUrl = aEmbeddedUrl.AllocLC(); |
|
521 TPtr ptr = embeddedUrl->Des(); |
|
522 _LIT( KBackslash, "\\" ); |
|
523 for ( TInt pos = ptr.Locate('/'); pos >= 0; pos = ptr.Locate('/') ) |
|
524 { |
|
525 ptr.Replace( pos, 1, KBackslash ); |
|
526 } |
|
527 |
|
528 // Check whether given url refers to file in the temporary html folder |
|
529 TInt pos = embeddedUrl->FindF( iTempHtmlFolderPath ); |
|
530 if ( pos >= 0 ) |
|
531 { |
|
532 TPtrC filename = embeddedUrl->Mid( pos + iTempHtmlFolderPath.Length() ); |
|
533 linkResolved = ResolveLinkL( filename, EFalse, aEmbeddedLinkContent ); |
|
534 } |
|
535 |
|
536 CleanupStack::PopAndDestroy( embeddedUrl ); |
|
537 } |
|
538 |
|
539 // Return whether link is resolved by host application. |
|
540 return linkResolved; |
|
541 } |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // From MBrCtlLinkResolver. |
|
545 // --------------------------------------------------------------------------- |
|
546 // |
|
547 TBool CFsEmailUiHtmlViewerContainer::ResolveLinkL( const TDesC& aUrl, |
|
548 const TDesC& /*aCurrentUrl*/, MBrCtlLinkContent& /*aBrCtlLinkContent*/ ) |
|
549 { |
|
550 FUNC_LOG; |
|
551 return iEventHandler->HandleEventL( aUrl ); |
|
552 } |
|
553 |
|
554 // --------------------------------------------------------------------------- |
|
555 // From MBrCtlLinkResolver. |
|
556 // --------------------------------------------------------------------------- |
|
557 // |
|
558 void CFsEmailUiHtmlViewerContainer::CancelAll() |
|
559 { |
|
560 FUNC_LOG; |
|
561 } |
|
562 |
|
563 // --------------------------------------------------------------------------- |
|
564 // From MBrCtlSoftkeysObserver |
|
565 // --------------------------------------------------------------------------- |
|
566 // |
|
567 void CFsEmailUiHtmlViewerContainer::UpdateSoftkeyL( |
|
568 TBrCtlKeySoftkey /*aKeySoftkey*/, const TDesC& /*aLabel*/, |
|
569 TUint32 /*aCommandId*/, |
|
570 TBrCtlSoftkeyChangeReason /*aBrCtlSoftkeyChangeReason*/ ) |
|
571 { |
|
572 FUNC_LOG; |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // Set HTML folder path name |
|
577 // --------------------------------------------------------------------------- |
|
578 // |
|
579 void CFsEmailUiHtmlViewerContainer::SetHtmlFolderPathL() |
|
580 { |
|
581 FUNC_LOG; |
|
582 iHtmlFolderPath.Copy( KCDrive ); |
|
583 |
|
584 TFileName privatePath; |
|
585 User::LeaveIfError( iFs.PrivatePath( privatePath ) ); |
|
586 iHtmlFolderPath.Append( privatePath ); |
|
587 |
|
588 iHtmlFolderPath.Append( KHtmlPath ); |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------------------------- |
|
592 // Sets temporary HTML folder path name |
|
593 // --------------------------------------------------------------------------- |
|
594 // |
|
595 void CFsEmailUiHtmlViewerContainer::SetTempHtmlFolderPath() |
|
596 { |
|
597 FUNC_LOG; |
|
598 iTempHtmlFolderPath.Copy( iHtmlFolderPath ); |
|
599 iTempHtmlFolderPath.Append( KTempHtmlPath ); |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------------------------- |
|
603 // Remove all previously created files from temporary HTML folder |
|
604 // --------------------------------------------------------------------------- |
|
605 // |
|
606 void CFsEmailUiHtmlViewerContainer::EmptyTempHtmlFolderL() |
|
607 { |
|
608 FUNC_LOG; |
|
609 // Delete all files from temp folder |
|
610 TFileName allFiles; |
|
611 allFiles.Append( iTempHtmlFolderPath ); |
|
612 allFiles.Append( KAllFiles ); |
|
613 TInt err = BaflUtils::DeleteFile( iFs, allFiles ); |
|
614 if ( err != KErrNotFound && err != KErrNone ) |
|
615 { |
|
616 User::LeaveIfError( err ); |
|
617 } |
|
618 } |
|
619 |
|
620 // --------------------------------------------------------------------------- |
|
621 // Copies given read-only file to HTML file |
|
622 // --------------------------------------------------------------------------- |
|
623 // |
|
624 // <cmail> |
|
625 void CFsEmailUiHtmlViewerContainer::CopyFileToHtmlFileL( RFile& aFile, |
|
626 const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart ) |
|
627 { |
|
628 FUNC_LOG; |
|
629 TFileName targetFileName; |
|
630 targetFileName.Copy( iTempHtmlFolderPath ); |
|
631 targetFileName.Append( aFileName ); |
|
632 |
|
633 // Read content from given source file |
|
634 HBufC8* content = ReadContentFromFileLC( aFile ); |
|
635 |
|
636 // Write content to target file |
|
637 WriteContentToFileL( *content, targetFileName, aHtmlBodyPart ); |
|
638 |
|
639 CleanupStack::PopAndDestroy( content ); |
|
640 } |
|
641 // </cmail> |
|
642 |
|
643 // --------------------------------------------------------------------------- |
|
644 // Copies given buffer to HTML file |
|
645 // --------------------------------------------------------------------------- |
|
646 // |
|
647 // <cmail> |
|
648 void CFsEmailUiHtmlViewerContainer::CopyFileToHtmlFileL( const TDesC8& aBuffer, |
|
649 const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart ) |
|
650 { |
|
651 FUNC_LOG; |
|
652 TFileName targetFileName; |
|
653 targetFileName.Copy( iTempHtmlFolderPath ); |
|
654 targetFileName.Append( aFileName ); |
|
655 |
|
656 // Write content to target file |
|
657 ConvertToHTML( aBuffer, targetFileName, aHtmlBodyPart ); |
|
658 } |
|
659 |
|
660 // --------------------------------------------------------------------------- |
|
661 // Reads given file content to buffer and return pointer to it |
|
662 // --------------------------------------------------------------------------- |
|
663 // |
|
664 HBufC8* CFsEmailUiHtmlViewerContainer::ReadContentFromFileLC( RFile& aFile ) |
|
665 { |
|
666 FUNC_LOG; |
|
667 TInt size = 0; |
|
668 User::LeaveIfError( aFile.Size( size ) ); |
|
669 HBufC8* buffer = HBufC8::NewLC( size ); |
|
670 TPtr8 ptr = buffer->Des(); |
|
671 User::LeaveIfError( aFile.Read( ptr, size ) ); |
|
672 return buffer; |
|
673 } |
|
674 |
|
675 // --------------------------------------------------------------------------- |
|
676 // Writes buffer content to given file |
|
677 // --------------------------------------------------------------------------- |
|
678 // |
|
679 // <cmail> |
|
680 void CFsEmailUiHtmlViewerContainer::WriteContentToFileL( const TDesC8& aContent, |
|
681 const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart ) |
|
682 { |
|
683 FUNC_LOG; |
|
684 |
|
685 RBuf8 buffer; |
|
686 buffer.CreateL( aContent ); |
|
687 buffer.CleanupClosePushL(); |
|
688 |
|
689 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, buffer.Size(), EDriveC ) ) |
|
690 { |
|
691 // Can not write the data, there's not enough free space on disk. |
|
692 User::Leave( KErrDiskFull ); |
|
693 } |
|
694 else |
|
695 { |
|
696 RFile targetFile; |
|
697 CleanupClosePushL( targetFile ); |
|
698 |
|
699 User::LeaveIfError( targetFile.Replace( iFs, aFileName, EFileWrite ) ); |
|
700 |
|
701 // Try to find initial html tag (both '<html' and '<HTML' versions are searched) |
|
702 TInt startTagOffset = buffer.Left( KMaxCharsToSearch ).FindF( KStartTag ); |
|
703 |
|
704 // Modifying text/html atta IF there's no '<html>' tag anywhere in |
|
705 // the begining of file (KMaxCharsToSearch) AND there is charset |
|
706 // parameter available |
|
707 TBool modificationNeeded( EFalse ); |
|
708 if( startTagOffset == KErrNotFound ) |
|
709 { |
|
710 modificationNeeded = ETrue; |
|
711 } |
|
712 |
|
713 // Write starting metadata if needed |
|
714 if ( modificationNeeded ) |
|
715 { |
|
716 HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart ); |
|
717 CleanupStack::PushL( charSet ); |
|
718 |
|
719 User::LeaveIfError( targetFile.Write( KHtmlHeader1 ) ); |
|
720 User::LeaveIfError( targetFile.Write( *charSet ) ); |
|
721 User::LeaveIfError( targetFile.Write( KHtmlHeader2 ) ); |
|
722 CleanupStack::PopAndDestroy( charSet ); |
|
723 } |
|
724 else |
|
725 { |
|
726 // Charset tag not found in html body |
|
727 |
|
728 if ( buffer.Left( KMaxCharsToSearch ).FindF( KCharsetTag8 ) == KErrNotFound ) |
|
729 { |
|
730 TInt startPos(0); |
|
731 if ( ( startPos = buffer.Left( KMaxCharsToSearch ).FindF( KHeadTag ) ) != KErrNotFound ) |
|
732 { |
|
733 |
|
734 HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart ); |
|
735 CleanupStack::PushL( charSet ); |
|
736 |
|
737 HBufC8* metaBuffer = HBufC8::NewLC( charSet->Des().Length() + KHtmlHeader3().Length() ); |
|
738 TPtr8 metaHeader( metaBuffer->Des() ); |
|
739 metaHeader.AppendFormat( KHtmlHeader3, charSet ); |
|
740 TInt maxLength = buffer.Length() + metaHeader.Length(); |
|
741 buffer.ReAllocL( maxLength ); |
|
742 |
|
743 startPos += KHeadTag().Length(); |
|
744 buffer.Insert( startPos, metaHeader ); |
|
745 |
|
746 CleanupStack::PopAndDestroy( metaBuffer ); |
|
747 CleanupStack::PopAndDestroy( charSet ); |
|
748 } |
|
749 } |
|
750 } |
|
751 |
|
752 // Write the original content |
|
753 User::LeaveIfError( targetFile.Write( buffer ) ); |
|
754 |
|
755 // Write ending metadata if needed |
|
756 if ( modificationNeeded ) |
|
757 { |
|
758 INFO("Add end tags"); |
|
759 User::LeaveIfError( targetFile.Write( KHtmlEndTags ) ); |
|
760 } |
|
761 |
|
762 CleanupStack::PopAndDestroy( &targetFile ); |
|
763 } |
|
764 CleanupStack::PopAndDestroy( &buffer ); |
|
765 // </cmail> |
|
766 } |
|
767 |
|
768 // --------------------------------------------------------------------------- |
|
769 // Finds the attachment from the list that matches the given content ID |
|
770 // --------------------------------------------------------------------------- |
|
771 // |
|
772 CFSMailMessagePart* CFsEmailUiHtmlViewerContainer::MatchingAttacmentL( |
|
773 const TDesC& aContentId, |
|
774 const RPointerArray<CFSMailMessagePart>& aAttachments ) const |
|
775 { |
|
776 FUNC_LOG; |
|
777 TBool contentFound = EFalse; |
|
778 CFSMailMessagePart* attachment = NULL; |
|
779 TInt attachmentCount = aAttachments.Count(); |
|
780 |
|
781 // Check whether one of the attachments has the given conten ID |
|
782 for ( TInt i = 0; i < attachmentCount && !contentFound; i++ ) |
|
783 { |
|
784 attachment = aAttachments[i]; |
|
785 const TDesC& contentId = attachment->ContentID(); |
|
786 if ( contentId.Compare( aContentId ) == 0 ) |
|
787 { |
|
788 contentFound = ETrue; |
|
789 } |
|
790 } |
|
791 |
|
792 // If attacment with given content ID was not found, check whether |
|
793 // the given content ID contains the name of one of the attachments |
|
794 for ( TInt i = 0; i < attachmentCount && !contentFound; ++i ) |
|
795 { |
|
796 attachment = aAttachments[i]; |
|
797 const TDesC& name = attachment->AttachmentNameL(); |
|
798 if ( aContentId.FindF( name ) >= 0 ) |
|
799 { |
|
800 contentFound = ETrue; |
|
801 } |
|
802 } |
|
803 |
|
804 if ( !contentFound ) |
|
805 { |
|
806 attachment = NULL; |
|
807 } |
|
808 return attachment; |
|
809 } |
|
810 |
|
811 // --------------------------------------------------------------------------- |
|
812 // Resolves link referring to file in temporary HTML folder |
|
813 // --------------------------------------------------------------------------- |
|
814 // |
|
815 TBool CFsEmailUiHtmlViewerContainer::ResolveLinkL( const TDesC& aLink, |
|
816 TBool aContentId, MBrCtlLinkContent& aEmbeddedLinkContent ) |
|
817 { |
|
818 FUNC_LOG; |
|
819 TBool linkResolved = EFalse; |
|
820 CFSMailMessagePart* attachment = NULL; |
|
821 |
|
822 RPointerArray<CFSMailMessagePart> attachments; |
|
823 CleanupResetAndDestroyClosePushL( attachments ); |
|
824 iMessage->AttachmentListL( attachments ); |
|
825 |
|
826 if ( aContentId ) |
|
827 { |
|
828 attachment = MatchingAttacmentL( aLink, attachments ); |
|
829 } |
|
830 else |
|
831 { |
|
832 const TInt attachmentCount = attachments.Count(); |
|
833 for ( TInt ii = 0; ii < attachmentCount && !attachment; ++ii ) |
|
834 { |
|
835 if ( aLink.CompareF( attachments[ii]->AttachmentNameL() ) == 0 ) |
|
836 { |
|
837 attachment = attachments[ii]; |
|
838 } |
|
839 } |
|
840 } |
|
841 |
|
842 if ( attachment ) |
|
843 { |
|
844 DownloadAttachmentL( *attachment, aEmbeddedLinkContent ); |
|
845 linkResolved = ETrue; |
|
846 } |
|
847 |
|
848 CleanupStack::PopAndDestroy( &attachments ); |
|
849 return linkResolved; |
|
850 } |
|
851 |
|
852 // --------------------------------------------------------------------------- |
|
853 // Download attachment and return the content via MBrCtlLinkContent interface |
|
854 // --------------------------------------------------------------------------- |
|
855 // |
|
856 void CFsEmailUiHtmlViewerContainer::DownloadAttachmentL( |
|
857 CFSMailMessagePart& aAttachment, MBrCtlLinkContent& aEmbeddedLinkContent ) |
|
858 { |
|
859 FUNC_LOG; |
|
860 if ( aAttachment.FetchLoadState() == EFSFull ) |
|
861 { |
|
862 RFile attachmentFile = aAttachment.GetContentFileL(); |
|
863 CleanupClosePushL( attachmentFile ); |
|
864 HBufC8* content = ReadContentFromFileLC( attachmentFile ); |
|
865 aEmbeddedLinkContent.HandleResolveComplete( |
|
866 aAttachment.GetContentType(), KNullDesC(), content ); |
|
867 CleanupStack::PopAndDestroy( content ); |
|
868 CleanupStack::PopAndDestroy( &attachmentFile ); |
|
869 } |
|
870 else |
|
871 { |
|
872 TPartData partData; |
|
873 partData.iMailBoxId = iMessage->GetMailBoxId(); |
|
874 partData.iFolderId = iMessage->GetFolderId(); |
|
875 partData.iMessageId = iMessage->GetMessageId(); |
|
876 partData.iMessagePartId = aAttachment.GetPartId(); |
|
877 |
|
878 if ( iAppUi.DownloadInfoMediator() && |
|
879 iAppUi.DownloadInfoMediator()->IsDownloadableL( partData ) ) |
|
880 { |
|
881 ASSERT( iLinkContents.Count() == iMessageParts.Count() ); |
|
882 |
|
883 // Append message part details and embedded link content interface |
|
884 // to corresponding arrays so that the content can be returned |
|
885 // when the download is completed. |
|
886 iLinkContents.AppendL( &aEmbeddedLinkContent ); |
|
887 if ( iMessageParts.Append( partData ) != KErrNone ) |
|
888 { |
|
889 iLinkContents.Remove( iLinkContents.Count() - 1 ); |
|
890 } |
|
891 |
|
892 ASSERT( iLinkContents.Count() == iMessageParts.Count() ); |
|
893 if(!iView.GetAsyncFetchStatus()) |
|
894 { |
|
895 iAppUi.DownloadInfoMediator()->AddObserver( this, aAttachment.GetMessageId() ); |
|
896 iObservingDownload=ETrue; |
|
897 iAppUi.DownloadInfoMediator()->DownloadL( partData, EFalse ); |
|
898 } |
|
899 } |
|
900 } |
|
901 } |
|
902 |
|
903 void CFsEmailUiHtmlViewerContainer::SetHTMLResourceFlagFullName() |
|
904 { |
|
905 FUNC_LOG; |
|
906 iHtmlResourceFlagPath.Copy( iHtmlFolderPath ); |
|
907 iHtmlResourceFlagPath.Append( KHtmlFlagFile ); |
|
908 } |
|
909 |
|
910 void CFsEmailUiHtmlViewerContainer::EnableHTMLResourceFlagL() |
|
911 { |
|
912 FUNC_LOG; |
|
913 RFile flag; |
|
914 User::LeaveIfError( flag.Replace(iFs, iHtmlResourceFlagPath, EFileWrite) ); |
|
915 flag.Close(); |
|
916 } |
|
917 |
|
918 TBool CFsEmailUiHtmlViewerContainer::HTMLResourceFlagEnabled() |
|
919 { |
|
920 FUNC_LOG; |
|
921 return BaflUtils::FileExists( iFs, iHtmlResourceFlagPath ); |
|
922 } |
|
923 |
|
924 void CFsEmailUiHtmlViewerContainer::CopyHTMLResourceL() |
|
925 { |
|
926 FUNC_LOG; |
|
927 |
|
928 TPath htmlFolderPathInZ; |
|
929 htmlFolderPathInZ.Copy( KZDrive ); |
|
930 |
|
931 TFileName privatePath; |
|
932 User::LeaveIfError( iFs.PrivatePath( privatePath ) ); |
|
933 htmlFolderPathInZ.Append( privatePath ); |
|
934 |
|
935 htmlFolderPathInZ.Append( KHtmlPath ); |
|
936 |
|
937 CDir* dirList; |
|
938 TPath listSpec; |
|
939 listSpec.Copy( htmlFolderPathInZ ); |
|
940 |
|
941 listSpec.Append( _L("*.*") ); |
|
942 User::LeaveIfError( iFs.GetDir( listSpec, KEntryAttMaskSupported, ESortByName, dirList ) ); |
|
943 CleanupStack::PushL( dirList ); |
|
944 for ( TInt i=0; i < dirList->Count(); i++) |
|
945 { |
|
946 TPath sourceFileFullName; |
|
947 sourceFileFullName.Copy( htmlFolderPathInZ ); |
|
948 sourceFileFullName.Append( (*dirList)[i].iName ); |
|
949 |
|
950 TBool isFolder( EFalse ); |
|
951 BaflUtils::IsFolder( iFs, sourceFileFullName, isFolder); |
|
952 if ( isFolder ) |
|
953 { |
|
954 break; |
|
955 } |
|
956 |
|
957 TPath targetFileFullName; |
|
958 targetFileFullName.Copy( iHtmlFolderPath ); |
|
959 targetFileFullName.Append( (*dirList)[i].iName ); |
|
960 BaflUtils::DeleteFile( iFs, targetFileFullName ); |
|
961 |
|
962 BaflUtils::CopyFile( iFs, sourceFileFullName, targetFileFullName); |
|
963 } |
|
964 CleanupStack::PopAndDestroy( dirList ); |
|
965 } |
|
966 |
|
967 void CFsEmailUiHtmlViewerContainer::EnsureHTMLResourceL() |
|
968 { |
|
969 FUNC_LOG; |
|
970 |
|
971 if ( !HTMLResourceFlagEnabled() ) |
|
972 { |
|
973 CopyHTMLResourceL(); |
|
974 EnableHTMLResourceFlagL(); |
|
975 } |
|
976 } |
|
977 |
|
978 // --------------------------------------------------------------------------- |
|
979 // Writes buffer content to given file after adding tags |
|
980 // --------------------------------------------------------------------------- |
|
981 // |
|
982 // <cmail> |
|
983 void CFsEmailUiHtmlViewerContainer::ConvertToHTML( const TDesC8& aContent, |
|
984 const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart ) |
|
985 { |
|
986 FUNC_LOG; |
|
987 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, aContent.Size(), EDriveC ) ) |
|
988 { |
|
989 // Can not write the data, there's not enough free space on disk. |
|
990 User::Leave( KErrDiskFull ); |
|
991 } |
|
992 else |
|
993 { |
|
994 RFile targetFile; |
|
995 CleanupClosePushL( targetFile ); |
|
996 |
|
997 User::LeaveIfError( targetFile.Replace( iFs, aFileName, EFileWrite ) ); |
|
998 |
|
999 HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart ); |
|
1000 CleanupStack::PushL( charSet ); |
|
1001 |
|
1002 User::LeaveIfError( targetFile.Write( KHtmlHeader1 ) ); |
|
1003 User::LeaveIfError( targetFile.Write( *charSet ) ); |
|
1004 User::LeaveIfError( targetFile.Write( KHtmlHeader2 ) ); |
|
1005 CleanupStack::PopAndDestroy( charSet ); |
|
1006 |
|
1007 |
|
1008 // Write the original content |
|
1009 for(int i=0;i<aContent.Length();i++) |
|
1010 { |
|
1011 if( i==aContent.Length()-1 ) |
|
1012 { |
|
1013 aContent.Mid( i,1 ).CompareC( _L8("\x01" ) )==0 ? |
|
1014 User::LeaveIfError( targetFile.Write( _L8("<br>") ) ): |
|
1015 User::LeaveIfError( targetFile.Write( aContent.Mid(i,1) ) ); |
|
1016 } |
|
1017 else |
|
1018 { |
|
1019 if(aContent.Mid( i,1 ).CompareC( _L8("\x01" ) )==0 || |
|
1020 aContent.Mid( i,2 ).CompareC( _L8("\x0D\x0A" ) )==0 ) |
|
1021 { |
|
1022 User::LeaveIfError( targetFile.Write( _L8("<br>") )); |
|
1023 } |
|
1024 else |
|
1025 { |
|
1026 User::LeaveIfError( targetFile.Write( aContent.Mid(i,1) ) ); |
|
1027 } |
|
1028 } |
|
1029 } |
|
1030 INFO("Add end tags"); |
|
1031 User::LeaveIfError( targetFile.Write( KHtmlEndTags ) ); |
|
1032 |
|
1033 |
|
1034 CleanupStack::PopAndDestroy( &targetFile ); |
|
1035 } |
|
1036 // </cmail> |
|
1037 } |
|
1038 |
|
1039 |
|
1040 // --------------------------------------------------------------------------- |
|
1041 // Get Character set from CFSMailMessagePart |
|
1042 // --------------------------------------------------------------------------- |
|
1043 // |
|
1044 // <cmail> |
|
1045 HBufC8* CFsEmailUiHtmlViewerContainer::GetCharacterSetL( CFSMailMessagePart& aHtmlBodyPart ) |
|
1046 { |
|
1047 FUNC_LOG; |
|
1048 |
|
1049 CDesCArray& contentTypeArray( aHtmlBodyPart.ContentTypeParameters() ); |
|
1050 HBufC8* charSet = KNullDesC8().AllocLC(); |
|
1051 |
|
1052 for ( TInt i = 0; i < contentTypeArray.Count(); i++ ) |
|
1053 { |
|
1054 if ( ( contentTypeArray.MdcaPoint( i ).Find( KCharsetTag ) != KErrNotFound ) && |
|
1055 contentTypeArray.Count() >= ( i+1) ) |
|
1056 { |
|
1057 TPtrC value( contentTypeArray.MdcaPoint( i+1 ) ); |
|
1058 if ( value.Length() ) |
|
1059 { |
|
1060 CleanupStack::PopAndDestroy( charSet ); |
|
1061 charSet = NULL; |
|
1062 charSet = HBufC8::NewLC( value.Length() ); |
|
1063 charSet->Des().Copy( value ); |
|
1064 break; |
|
1065 } |
|
1066 } |
|
1067 i++; |
|
1068 } |
|
1069 |
|
1070 CleanupStack::Pop( charSet ); |
|
1071 return charSet; |
|
1072 } |
|
1073 void CFsEmailUiHtmlViewerContainer::StopObserving() |
|
1074 { |
|
1075 if( iObservingDownload ) |
|
1076 { |
|
1077 if ( iMessage && iAppUi.DownloadInfoMediator() ) |
|
1078 { |
|
1079 iAppUi.DownloadInfoMediator()->StopObserving( this, iMessage->GetMessageId() ); |
|
1080 } |
|
1081 iObservingDownload=EFalse; |
|
1082 } |
|
1083 } |
|
1084 |
|
1085 void CFsEmailUiHtmlViewerContainer::CancelFetch() |
|
1086 { |
|
1087 FUNC_LOG; |
|
1088 if ( iBrCtlInterface ) |
|
1089 { |
|
1090 TRAP_IGNORE( iBrCtlInterface->HandleCommandL( (TInt)TBrCtlDefs::ECommandCancelFetch + (TInt)TBrCtlDefs::ECommandIdBase )); |
|
1091 } |
|
1092 } |
|
1093 |
|
1094 void CFsEmailUiHtmlViewerContainer::ClearCacheAndLoadEmptyContent() |
|
1095 { |
|
1096 FUNC_LOG; |
|
1097 if ( iBrCtlInterface ) |
|
1098 { |
|
1099 iBrCtlInterface->ClearCache(); |
|
1100 TUid uid; |
|
1101 uid.iUid = KCharacterSetIdentifierUtf8; |
|
1102 TRAP_IGNORE( iBrCtlInterface->LoadDataL(KHTMLDataScheme, KHTMLEmptyContent, _L8("text/html"), uid) ); |
|
1103 } |
|
1104 } |