author | Fionntina Carville <fionntinac@symbian.org> |
Mon, 15 Nov 2010 10:30:54 +0000 | |
branch | RCL_3 |
changeset 82 | 28205c20df94 |
parent 80 | 726fba06891a |
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 definition |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#ifndef __FREESTYLEEMAILUI_HTML_VIEWER_CONTAINER_H__ |
|
21 |
#define __FREESTYLEEMAILUI_HTML_VIEWER_CONTAINER_H__ |
|
22 |
||
23 |
||
24 |
#include <coecntrl.h> |
|
25 |
#include <brctlspecialloadobserver.h> |
|
26 |
#include <brctllinkresolver.h> |
|
27 |
||
28 |
#include "FreestyleEmailUiAknStatusIndicator.h" |
|
29 |
#include "FreestyleEmailDownloadInformationMediator.h" |
|
30 |
#include "freestyleemailcenrepkeys.h" |
|
31 |
#include "OverlayControl.h" |
|
32 |
||
33 |
class CFSMailMessage; |
|
34 |
class CFreestyleEmailUiAppUi; |
|
35 |
class CFreestyleMessageHeaderURLEventHandler; |
|
36 |
struct TAttachmentData; |
|
37 |
class CFsEmailUiHtmlViewerContainer; |
|
38 |
class MTouchFeedback; |
|
39 |
class CFindItemEngine; |
|
40 |
||
41 |
/** |
|
42 |
* Single key listener |
|
43 |
*/ |
|
44 |
class CEUiHtmlViewerSettingsKeyListener : public CActive |
|
45 |
{ |
|
46 |
public: |
|
47 |
/** |
|
48 |
* Observer interface for key value changes |
|
49 |
*/ |
|
50 |
class MObserver |
|
51 |
{ |
|
52 |
public: |
|
53 |
/** |
|
54 |
* Called when key value changes |
|
55 |
*/ |
|
56 |
virtual void KeyValueChangedL( TUint32 aKey ) = 0; |
|
57 |
||
58 |
/** |
|
59 |
* Listener can query repository instance using this method. No need |
|
60 |
* to create own repository instance OR to store repository reference. |
|
61 |
*/ |
|
62 |
virtual CRepository& Repository() = 0; |
|
63 |
}; |
|
64 |
public: |
|
65 |
/** |
|
66 |
* Constructor |
|
67 |
*/ |
|
68 |
CEUiHtmlViewerSettingsKeyListener( MObserver& aObserver, TUint32 aKey ); |
|
69 |
||
70 |
/** |
|
71 |
* Destructor |
|
72 |
*/ |
|
73 |
~CEUiHtmlViewerSettingsKeyListener(); |
|
74 |
||
75 |
private: |
|
76 |
/** |
|
77 |
* Start listening value changes |
|
78 |
*/ |
|
79 |
void StartListening(); |
|
80 |
||
81 |
private: // from CActive |
|
82 |
/** |
|
83 |
* @see CActive::RunL |
|
84 |
*/ |
|
85 |
void RunL(); |
|
86 |
||
87 |
/** |
|
88 |
* @see CActive::DoCancel |
|
89 |
*/ |
|
90 |
void DoCancel(); |
|
91 |
||
92 |
private: |
|
93 |
/** |
|
94 |
* Key observer |
|
95 |
*/ |
|
96 |
MObserver& iObserver; |
|
97 |
||
98 |
/** |
|
99 |
* Key id |
|
100 |
*/ |
|
101 |
TUint32 iKey; |
|
102 |
}; |
|
103 |
||
104 |
||
105 |
/** |
|
106 |
* HTML viewer settings class. |
|
107 |
*/ |
|
108 |
class CEUiHtmlViewerSettings : public CBase, public CEUiHtmlViewerSettingsKeyListener::MObserver |
|
109 |
{ |
|
110 |
||
111 |
public: |
|
112 |
||
113 |
/** |
|
114 |
* Settings observer interface |
|
115 |
*/ |
|
116 |
class MObserver |
|
117 |
{ |
|
118 |
public: |
|
119 |
/** |
|
120 |
* Called when a setting value has changed. |
|
121 |
*/ |
|
122 |
virtual void ViewerSettingsChangedL( const TUint32 aKey ) = 0; |
|
123 |
}; |
|
124 |
||
125 |
public: |
|
126 |
||
127 |
/** |
|
128 |
* Static constructor |
|
129 |
*/ |
|
130 |
static CEUiHtmlViewerSettings* NewL( MObserver& aObserver ); |
|
131 |
||
132 |
/** |
|
133 |
* Destructor |
|
134 |
*/ |
|
135 |
~CEUiHtmlViewerSettings(); |
|
136 |
||
137 |
/** |
|
138 |
* Boolean value for auto load image setting |
|
139 |
*/ |
|
140 |
TBool AutoLoadImages() const; |
|
141 |
||
142 |
private: |
|
143 |
||
144 |
CEUiHtmlViewerSettings( MObserver& aObserver ); |
|
145 |
void ConstructL(); |
|
146 |
void AddKeyListenerL( TUint32 aKey ); |
|
147 |
void UpdateValue( TUint32 aKey ); |
|
148 |
||
149 |
private: // from CEUiHtmlViewerSettingsKeyListener::MObserver |
|
150 |
||
151 |
/** |
|
152 |
* @see CEUiHtmlViewerSettingsKeyListener::MObserver::KeyValueChangedL |
|
153 |
*/ |
|
154 |
void KeyValueChangedL( TUint32 aKey ); |
|
155 |
||
156 |
public: |
|
157 |
/** |
|
158 |
* @see CEUiHtmlViewerSettingsKeyListener::MObserver::Repository |
|
159 |
*/ |
|
160 |
CRepository& Repository(); |
|
161 |
||
162 |
private: |
|
163 |
||
164 |
enum TFlag |
|
165 |
{ |
|
166 |
EAutoLoadImages = KFreestyleEmailDownloadHTMLImages |
|
167 |
}; |
|
168 |
||
169 |
MObserver& iObserver; |
|
170 |
CRepository* iRepository; |
|
171 |
TBitFlags iFlags; |
|
172 |
RPointerArray<CEUiHtmlViewerSettingsKeyListener> iKeyListeners; |
|
173 |
}; |
|
174 |
||
175 |
/** |
|
176 |
* Html viewer container. |
|
177 |
*/ |
|
178 |
class CFsEmailUiHtmlViewerContainer : public CCoeControl, |
|
179 |
public MBrCtlSpecialLoadObserver, |
|
180 |
public MBrCtlLinkResolver, |
|
181 |
public MBrCtlSoftkeysObserver, |
|
182 |
public MFSEmailDownloadInformationObserver, |
|
183 |
public MOverlayControlObserver, |
|
184 |
public MBrCtlWindowObserver, |
|
185 |
public CEUiHtmlViewerSettings::MObserver |
|
186 |
{ |
|
187 |
public: |
|
188 |
||
189 |
/** Two-phased constructor. */ |
|
190 |
static CFsEmailUiHtmlViewerContainer* NewL( CFreestyleEmailUiAppUi& aAppUi, |
|
191 |
CFsEmailUiHtmlViewerView& aView ); |
|
192 |
/** Destrcutor. */ |
|
193 |
~CFsEmailUiHtmlViewerContainer(); |
|
194 |
||
195 |
CBrCtlInterface* BrowserControlIf(); |
|
196 |
void LoadContentFromFileL( const TDesC& aFileName ); |
|
197 |
void LoadContentFromFileL( RFile& aFile ); |
|
198 |
void LoadContentFromUrlL( const TDesC& aUrl ); |
|
199 |
void LoadContentFromMailMessageL( CFSMailMessage* aMailMessage, TBool aResetScrollPos=ETrue ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
200 |
void ResetContent(const TBool aDisconnect = EFalse); |
64 | 201 |
void CancelFetch(); |
202 |
void ClearCacheAndLoadEmptyContent(); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
203 |
// <cmail> |
64 | 204 |
void PrepareForExit(); |
205 |
void PrepareForMessageNavigation(); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
206 |
// </cmail> |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
70
diff
changeset
|
207 |
|
64 | 208 |
// from base class CCoeControl |
209 |
||
210 |
CCoeControl* ComponentControl( TInt aIndex ) const; |
|
211 |
TInt CountComponentControls() const; |
|
212 |
void Draw( const TRect& aRect ) const; |
|
213 |
void SizeChanged(); |
|
214 |
TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
215 |
void HandleResourceChange(TInt aType); |
|
216 |
void MakeVisible( TBool aVisible ); |
|
217 |
||
218 |
// from base class MBrCtlSpecialLoadObserver |
|
219 |
||
220 |
void NetworkConnectionNeededL( TInt* aConnectionPtr, TInt* aSockSvrHandle, |
|
221 |
TBool* aNewConn, TApBearerType* aBearerType ); |
|
222 |
TBool HandleRequestL( RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray ); |
|
223 |
TBool HandleDownloadL( RArray<TUint>* aTypeArray, CDesCArrayFlat* aDesArray ); |
|
224 |
||
225 |
// from base class MFSEmailDownloadInformationObserver |
|
226 |
||
227 |
void RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart ); |
|
228 |
||
229 |
// from base class MBrCtlLinkResolver |
|
230 |
||
231 |
TBool ResolveEmbeddedLinkL( const TDesC& aEmbeddedUrl, |
|
232 |
const TDesC& aCurrentUrl, TBrCtlLoadContentType aLoadContentType, |
|
233 |
MBrCtlLinkContent& aEmbeddedLinkContent ); |
|
234 |
TBool ResolveLinkL( const TDesC& aUrl, const TDesC& aCurrentUrl, |
|
235 |
MBrCtlLinkContent& aBrCtlLinkContent ); |
|
236 |
void CancelAll(); |
|
237 |
||
238 |
// from base class MBrCtlSoftkeysObserver |
|
239 |
||
240 |
void UpdateSoftkeyL( TBrCtlKeySoftkey aKeySoftkey, const TDesC& aLabel, |
|
241 |
TUint32 aCommandId, TBrCtlSoftkeyChangeReason aBrCtlSoftkeyChangeReason ); |
|
242 |
void StopObserving(); |
|
243 |
||
244 |
// from MOverlayControlObserver |
|
245 |
void HandleOverlayPointerEventL( COverlayControl* aControl, const TPointerEvent& aEvent ); |
|
246 |
||
247 |
/* |
|
248 |
* Reloads the header of the opened mail. |
|
249 |
*/ |
|
250 |
void RefreshCurrentMailHeader(); |
|
251 |
/** Handles asynchronous reload of page for case when orientation |
|
252 |
* changed |
|
253 |
*/ |
|
254 |
void ReloadPageL(); |
|
255 |
||
256 |
void ShowAttachmentDownloadStatusL( TFSProgress::TFSProgressStatus aProgressStatus, const TAttachmentData& aAttachmentData ); |
|
257 |
TBool AttachmentDownloadStatusVisible(); |
|
258 |
void HideDownloadStatus(); |
|
259 |
void DisplayStatusIndicatorL(TInt aDuration = KStatusIndicatorDefaultDuration); |
|
260 |
||
261 |
// Inform that maillist model has updated |
|
262 |
void MailListModelUpdatedL(); |
|
263 |
||
264 |
// Zoom handling |
|
265 |
void ZoomInL(); |
|
266 |
void ZoomOutL(); |
|
267 |
TInt ZoomLevelL() const; |
|
268 |
void SetZoomLevelL( const TInt aZoomLevel ); |
|
269 |
TInt MaxZoomLevel() const; |
|
270 |
||
271 |
private: |
|
272 |
||
273 |
static TInt DoZoom( TAny* aPtr ); |
|
274 |
void DoZoomL(); |
|
275 |
||
276 |
private: // from CEUiHtmlViewerSettings::MObserver |
|
277 |
||
278 |
/** |
|
279 |
* @see CEUiHtmlViewerSettings::MObserver::ViewerSettingsChangedL |
|
280 |
*/ |
|
281 |
void ViewerSettingsChangedL( const TUint32 aKey ); |
|
282 |
||
283 |
private: |
|
284 |
||
285 |
void CreateBrowserControlInterfaceL(); |
|
286 |
||
287 |
// Second phase constructor. |
|
288 |
void ConstructL(); |
|
289 |
// C++ constructor. |
|
290 |
CFsEmailUiHtmlViewerContainer( CFreestyleEmailUiAppUi& aAppUi, |
|
291 |
CFsEmailUiHtmlViewerView& aView ); |
|
292 |
||
293 |
// Set HTML folder path name |
|
294 |
void SetHtmlFolderPathL(); |
|
295 |
// Sets temporary HTML folder path name |
|
296 |
void SetTempHtmlFolderPath(); |
|
297 |
// Remove all previously created files from temporary HTML folder |
|
298 |
void EmptyTempHtmlFolderL(); |
|
299 |
// Copies given file to temporary HTML folder and returns an open file |
|
300 |
// handle to the created copy. |
|
301 |
// <cmail> |
|
302 |
void CopyToHtmlFileL( CFSMailMessagePart& aHtmlBodyPart, const TDesC& aFileName ); |
|
303 |
void ConvertToHtmlFileL( CFSMailMessagePart& aTextBodyPart, const TDesC& aHtmlFileName ); |
|
304 |
||
305 |
// Reads given file content to buffer and return pointer to it |
|
306 |
HBufC8* ReadContentFromFileLC( RFile& aFile, CFSMailMessagePart& aBodyPart ); |
|
307 |
// Writes buffer to given file |
|
308 |
void WriteContentToFileL( const TDesC8& aContent, const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart ); |
|
309 |
||
310 |
void PrepareBodyHtmlL( const TDesC& aFileName ); |
|
311 |
void WriteEmptyBodyHtmlL( const TDesC& aFileName ); |
|
312 |
||
313 |
// </cmail> |
|
314 |
// Finds the attachment from the list that matches the given content ID |
|
315 |
CFSMailMessagePart* MatchingAttacmentL( const TDesC& aContentId, |
|
316 |
const RPointerArray<CFSMailMessagePart>& aAttachments ) const; |
|
317 |
// Resolves embedded link referring to file in temporary HTML folder |
|
318 |
TBool ResolveLinkL( const TDesC& aLink, TBool aContentId, |
|
319 |
MBrCtlLinkContent& aEmbeddedLinkContent ); |
|
320 |
// Downloads and return attachment content via MBrCtlLinkContent interface |
|
321 |
void DownloadAttachmentL( CFSMailMessagePart& aAttachment, |
|
322 |
MBrCtlLinkContent& aEmbeddedLinkContent ); |
|
323 |
||
324 |
// Get area for overlay button |
|
325 |
TRect OverlayButtonRect( TBool aLeft ); |
|
326 |
||
327 |
// Update overlay button position and visibility |
|
328 |
void UpdateOverlayButtons( TBool aVisible ); |
|
329 |
||
330 |
void SetHTMLResourceFlagFullName(); |
|
331 |
void EnableHTMLResourceFlagL(); |
|
332 |
TBool HTMLResourceFlagEnabled(); |
|
333 |
void CopyHTMLResourceL(); |
|
334 |
// Ensure all resource files (eg. images) required by HTML display to be ready in C:\[private]\HtmlFile |
|
335 |
void EnsureHTMLResourceL(); |
|
336 |
void ConvertToHTML( const TDesC& aContent, |
|
337 |
const TDesC& aFileName, CFSMailMessagePart& aHtmlBodyPart ); |
|
338 |
HBufC8* GetCharacterSetL( CFSMailMessagePart& aHtmlBodyPart ); |
|
339 |
TBool IsMessageBodyURLL(const TDesC& aUrl); |
|
340 |
TInt TotalLengthOfItems( CFindItemEngine& aItemEngine ) const; |
|
341 |
||
342 |
//Returns ETrue of clicking on a link requires a browser to be launched |
|
343 |
TBool NeedToLaunchBrowserL( const TDesC& aUrl ); |
|
344 |
//Launch the browser as a standalone app |
|
345 |
void LaunchBrowserL( const TDesC& aUrl ); |
|
346 |
||
347 |
//from MBrCtlWindowObserver |
|
348 |
CBrCtlInterface* OpenWindowL( TDesC& aUrl, TDesC* aTargetName, |
|
349 |
TBool aUserInitiated, TAny* aReserved ); |
|
350 |
CBrCtlInterface* FindWindowL( const TDesC& aTargetName ) const; |
|
351 |
void HandleWindowCommandL( const TDesC& aTargetName, TBrCtlWindowCommand aCommand ); |
|
352 |
||
353 |
TRect CalcAttachmentStatusRect(); |
|
354 |
void TouchFeedback(); |
|
355 |
||
356 |
void WriteToFileL( const TDesC& aFileName, RBuf& aHtmlText ); |
|
357 |
||
70
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
358 |
HBufC* CreateModifiedUrlIfNeededL( const TDesC& aUrl ); |
968773a0b6ef
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
359 |
|
64 | 360 |
private: // data |
361 |
||
362 |
// Reference to AppUi. |
|
363 |
CFreestyleEmailUiAppUi& iAppUi; |
|
364 |
// Reference to Html viewer view. |
|
365 |
CFsEmailUiHtmlViewerView& iView; |
|
366 |
// Browser control interface. Own. |
|
367 |
CBrCtlInterface* iBrCtlInterface; |
|
368 |
// Message. Not own. |
|
369 |
CFSMailMessage* iMessage; |
|
370 |
RFile iFile; |
|
371 |
RFs iFs; |
|
372 |
RSocketServ iSocketServer; |
|
373 |
RConnection iConnection; |
|
374 |
TBool iFirstTime; |
|
375 |
||
376 |
// HTML folder path. |
|
377 |
TPath iHtmlFolderPath; |
|
378 |
// Temporary HTML folder path. |
|
379 |
TPath iTempHtmlFolderPath; |
|
380 |
// HTML resource flag file path |
|
381 |
TPath iHtmlResourceFlagPath; |
|
382 |
||
383 |
// Interfaces waiting for embedded link content. |
|
384 |
RPointerArray<MBrCtlLinkContent> iLinkContents; |
|
385 |
// Message parts being downloaded as embedded link content. |
|
386 |
RArray<TPartData> iMessageParts; |
|
387 |
CFreestyleMessageHeaderURLEventHandler* iEventHandler; |
|
388 |
TBool iObservingDownload; |
|
389 |
TInt iScrollPosition; |
|
390 |
COverlayControl* iOverlayControlNext; |
|
391 |
COverlayControl* iOverlayControlPrev; |
|
392 |
//way to keep track of the current image being displayed by the indicator |
|
393 |
TInt iAttachmentDownloadImageHandle; |
|
394 |
CFreestyleEmailUiAknStatusIndicator* iStatusIndicator; |
|
395 |
CEUiHtmlViewerSettings* iViewerSettings; |
|
396 |
||
397 |
TBool iHeaderExpanded; |
|
398 |
// tactile feed back -- not owned |
|
399 |
MTouchFeedback* iTouchFeedBack; |
|
400 |
TBitFlags iFlags; |
|
401 |
TInt iZoomLevel; |
|
402 |
}; |
|
403 |
||
404 |
||
405 |
/** |
|
406 |
* PlainTextToHtmlConverter |
|
407 |
* |
|
408 |
* PlainTextToHtmlConverter converts plain text to html. It adds html entities |
|
409 |
* and hyperlinks. |
|
410 |
*/ |
|
411 |
NONSHARABLE_CLASS (PlainTextToHtmlConverter) |
|
412 |
{ |
|
413 |
private: |
|
414 |
PlainTextToHtmlConverter(); |
|
415 |
||
416 |
public: |
|
417 |
static void PlainTextToHtmlL(const TDesC& aPlainText, RBuf& aHtmlText); |
|
418 |
||
419 |
private: |
|
420 |
static void ConvertTextL(const TDesC& aSource, RBuf& aTarget); |
|
421 |
static void ConvertUrlL(const TDesC& aSource, RBuf& aTarget); |
|
422 |
}; |
|
423 |
#endif // __FREESTYLEEMAILUI_HTML_VIEWER_CONTAINER_H__ |